Move logic related to WAL replay of Heap/Heap2 into its own file

This brings more clarity to heapam.c, by cleanly separating all the
logic related to WAL replay and the rest of Heap and Heap2, similarly
to other RMGRs like hash, btree, etc.

The header reorganization is also nice in heapam.c, cutting half of the
headers required.

Author: Li Yong
Reviewed-by: Sutou Kouhei, Michael Paquier
Discussion: https://postgr.es/m/EFE55E65-D7BD-4C6A-B630-91F43FD0771B@ebay.com
This commit is contained in:
Michael Paquier 2024-09-12 13:32:05 +09:00
parent 9fba1ed294
commit 00c76cf21c
5 changed files with 1366 additions and 1339 deletions

View File

@ -16,6 +16,7 @@ OBJS = \
heapam.o \
heapam_handler.o \
heapam_visibility.o \
heapam_xlog.o \
heaptoast.o \
hio.o \
pruneheap.o \

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -4,6 +4,7 @@ backend_sources += files(
'heapam.c',
'heapam_handler.c',
'heapam_visibility.c',
'heapam_xlog.c',
'heaptoast.c',
'hio.c',
'pruneheap.c',

View File

@ -14,6 +14,7 @@
#ifndef HEAPAM_H
#define HEAPAM_H
#include "access/heapam_xlog.h"
#include "access/relation.h" /* for backward compatibility */
#include "access/relscan.h"
#include "access/sdir.h"
@ -422,4 +423,28 @@ extern bool ResolveCminCmaxDuringDecoding(struct HTAB *tuplecid_data,
extern void HeapCheckForSerializableConflictOut(bool visible, Relation relation, HeapTuple tuple,
Buffer buffer, Snapshot snapshot);
/*
* heap_execute_freeze_tuple
* Execute the prepared freezing of a tuple with caller's freeze plan.
*
* Caller is responsible for ensuring that no other backend can access the
* storage underlying this tuple, either by holding an exclusive lock on the
* buffer containing it (which is what lazy VACUUM does), or by having it be
* in private storage (which is what CLUSTER and friends do).
*/
static inline void
heap_execute_freeze_tuple(HeapTupleHeader tuple, HeapTupleFreeze *frz)
{
HeapTupleHeaderSetXmax(tuple, frz->xmax);
if (frz->frzflags & XLH_FREEZE_XVAC)
HeapTupleHeaderSetXvac(tuple, FrozenTransactionId);
if (frz->frzflags & XLH_INVALID_XVAC)
HeapTupleHeaderSetXvac(tuple, InvalidTransactionId);
tuple->t_infomask = frz->t_infomask;
tuple->t_infomask2 = frz->t_infomask2;
}
#endif /* HEAPAM_H */