PostgreSQL Source Code  git master
heapam_xlog.h File Reference
#include "access/htup.h"
#include "access/xlogreader.h"
#include "lib/stringinfo.h"
#include "storage/buf.h"
#include "storage/bufpage.h"
#include "storage/relfilenode.h"
#include "utils/relcache.h"
Include dependency graph for heapam_xlog.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  xl_heap_delete
 
struct  xl_heap_truncate
 
struct  xl_heap_header
 
struct  xl_heap_insert
 
struct  xl_heap_multi_insert
 
struct  xl_multi_insert_tuple
 
struct  xl_heap_update
 
struct  xl_heap_prune
 
struct  xl_heap_vacuum
 
struct  xl_heap_lock
 
struct  xl_heap_lock_updated
 
struct  xl_heap_confirm
 
struct  xl_heap_inplace
 
struct  xl_heap_freeze_tuple
 
struct  xl_heap_freeze_page
 
struct  xl_heap_visible
 
struct  xl_heap_new_cid
 
struct  xl_heap_rewrite_mapping
 

Macros

#define XLOG_HEAP_INSERT   0x00
 
#define XLOG_HEAP_DELETE   0x10
 
#define XLOG_HEAP_UPDATE   0x20
 
#define XLOG_HEAP_TRUNCATE   0x30
 
#define XLOG_HEAP_HOT_UPDATE   0x40
 
#define XLOG_HEAP_CONFIRM   0x50
 
#define XLOG_HEAP_LOCK   0x60
 
#define XLOG_HEAP_INPLACE   0x70
 
#define XLOG_HEAP_OPMASK   0x70
 
#define XLOG_HEAP_INIT_PAGE   0x80
 
#define XLOG_HEAP2_REWRITE   0x00
 
#define XLOG_HEAP2_PRUNE   0x10
 
#define XLOG_HEAP2_VACUUM   0x20
 
#define XLOG_HEAP2_FREEZE_PAGE   0x30
 
#define XLOG_HEAP2_VISIBLE   0x40
 
#define XLOG_HEAP2_MULTI_INSERT   0x50
 
#define XLOG_HEAP2_LOCK_UPDATED   0x60
 
#define XLOG_HEAP2_NEW_CID   0x70
 
#define XLH_INSERT_ALL_VISIBLE_CLEARED   (1<<0)
 
#define XLH_INSERT_LAST_IN_MULTI   (1<<1)
 
#define XLH_INSERT_IS_SPECULATIVE   (1<<2)
 
#define XLH_INSERT_CONTAINS_NEW_TUPLE   (1<<3)
 
#define XLH_INSERT_ON_TOAST_RELATION   (1<<4)
 
#define XLH_INSERT_ALL_FROZEN_SET   (1<<5)
 
#define XLH_UPDATE_OLD_ALL_VISIBLE_CLEARED   (1<<0)
 
#define XLH_UPDATE_NEW_ALL_VISIBLE_CLEARED   (1<<1)
 
#define XLH_UPDATE_CONTAINS_OLD_TUPLE   (1<<2)
 
#define XLH_UPDATE_CONTAINS_OLD_KEY   (1<<3)
 
#define XLH_UPDATE_CONTAINS_NEW_TUPLE   (1<<4)
 
#define XLH_UPDATE_PREFIX_FROM_OLD   (1<<5)
 
#define XLH_UPDATE_SUFFIX_FROM_OLD   (1<<6)
 
#define XLH_UPDATE_CONTAINS_OLD    (XLH_UPDATE_CONTAINS_OLD_TUPLE | XLH_UPDATE_CONTAINS_OLD_KEY)
 
#define XLH_DELETE_ALL_VISIBLE_CLEARED   (1<<0)
 
#define XLH_DELETE_CONTAINS_OLD_TUPLE   (1<<1)
 
#define XLH_DELETE_CONTAINS_OLD_KEY   (1<<2)
 
#define XLH_DELETE_IS_SUPER   (1<<3)
 
#define XLH_DELETE_IS_PARTITION_MOVE   (1<<4)
 
#define XLH_DELETE_CONTAINS_OLD    (XLH_DELETE_CONTAINS_OLD_TUPLE | XLH_DELETE_CONTAINS_OLD_KEY)
 
#define SizeOfHeapDelete   (offsetof(xl_heap_delete, flags) + sizeof(uint8))
 
#define XLH_TRUNCATE_CASCADE   (1<<0)
 
#define XLH_TRUNCATE_RESTART_SEQS   (1<<1)
 
#define SizeOfHeapTruncate   (offsetof(xl_heap_truncate, relids))
 
#define SizeOfHeapHeader   (offsetof(xl_heap_header, t_hoff) + sizeof(uint8))
 
#define SizeOfHeapInsert   (offsetof(xl_heap_insert, flags) + sizeof(uint8))
 
#define SizeOfHeapMultiInsert   offsetof(xl_heap_multi_insert, offsets)
 
#define SizeOfMultiInsertTuple   (offsetof(xl_multi_insert_tuple, t_hoff) + sizeof(uint8))
 
#define SizeOfHeapUpdate   (offsetof(xl_heap_update, new_offnum) + sizeof(OffsetNumber))
 
#define SizeOfHeapPrune   (offsetof(xl_heap_prune, ndead) + sizeof(uint16))
 
#define SizeOfHeapVacuum   (offsetof(xl_heap_vacuum, nunused) + sizeof(uint16))
 
#define XLHL_XMAX_IS_MULTI   0x01
 
#define XLHL_XMAX_LOCK_ONLY   0x02
 
#define XLHL_XMAX_EXCL_LOCK   0x04
 
#define XLHL_XMAX_KEYSHR_LOCK   0x08
 
#define XLHL_KEYS_UPDATED   0x10
 
#define XLH_LOCK_ALL_FROZEN_CLEARED   0x01
 
#define SizeOfHeapLock   (offsetof(xl_heap_lock, flags) + sizeof(int8))
 
#define SizeOfHeapLockUpdated   (offsetof(xl_heap_lock_updated, flags) + sizeof(uint8))
 
#define SizeOfHeapConfirm   (offsetof(xl_heap_confirm, offnum) + sizeof(OffsetNumber))
 
#define SizeOfHeapInplace   (offsetof(xl_heap_inplace, offnum) + sizeof(OffsetNumber))
 
#define XLH_FREEZE_XVAC   0x02
 
#define XLH_INVALID_XVAC   0x04
 
#define SizeOfHeapFreezePage   (offsetof(xl_heap_freeze_page, ntuples) + sizeof(uint16))
 
#define SizeOfHeapVisible   (offsetof(xl_heap_visible, flags) + sizeof(uint8))
 
#define SizeOfHeapNewCid   (offsetof(xl_heap_new_cid, target_tid) + sizeof(ItemPointerData))
 

Typedefs

typedef struct xl_heap_delete xl_heap_delete
 
typedef struct xl_heap_truncate xl_heap_truncate
 
typedef struct xl_heap_header xl_heap_header
 
typedef struct xl_heap_insert xl_heap_insert
 
typedef struct xl_heap_multi_insert xl_heap_multi_insert
 
typedef struct xl_multi_insert_tuple xl_multi_insert_tuple
 
typedef struct xl_heap_update xl_heap_update
 
typedef struct xl_heap_prune xl_heap_prune
 
typedef struct xl_heap_vacuum xl_heap_vacuum
 
typedef struct xl_heap_lock xl_heap_lock
 
typedef struct xl_heap_lock_updated xl_heap_lock_updated
 
typedef struct xl_heap_confirm xl_heap_confirm
 
typedef struct xl_heap_inplace xl_heap_inplace
 
typedef struct xl_heap_freeze_tuple xl_heap_freeze_tuple
 
typedef struct xl_heap_freeze_page xl_heap_freeze_page
 
typedef struct xl_heap_visible xl_heap_visible
 
typedef struct xl_heap_new_cid xl_heap_new_cid
 
typedef struct xl_heap_rewrite_mapping xl_heap_rewrite_mapping
 

Functions

void HeapTupleHeaderAdvanceLatestRemovedXid (HeapTupleHeader tuple, TransactionId *latestRemovedXid)
 
void heap_redo (XLogReaderState *record)
 
void heap_desc (StringInfo buf, XLogReaderState *record)
 
const char * heap_identify (uint8 info)
 
void heap_mask (char *pagedata, BlockNumber blkno)
 
void heap2_redo (XLogReaderState *record)
 
void heap2_desc (StringInfo buf, XLogReaderState *record)
 
const char * heap2_identify (uint8 info)
 
void heap_xlog_logical_rewrite (XLogReaderState *r)
 
XLogRecPtr log_heap_freeze (Relation reln, Buffer buffer, TransactionId cutoff_xid, xl_heap_freeze_tuple *tuples, int ntuples)
 
bool heap_prepare_freeze_tuple (HeapTupleHeader tuple, TransactionId relfrozenxid, TransactionId relminmxid, TransactionId cutoff_xid, TransactionId cutoff_multi, xl_heap_freeze_tuple *frz, bool *totally_frozen, TransactionId *relfrozenxid_out, MultiXactId *relminmxid_out)
 
void heap_execute_freeze_tuple (HeapTupleHeader tuple, xl_heap_freeze_tuple *xlrec_tp)
 
XLogRecPtr log_heap_visible (RelFileNode rnode, Buffer heap_buffer, Buffer vm_buffer, TransactionId cutoff_xid, uint8 flags)
 

Macro Definition Documentation

◆ SizeOfHeapConfirm

#define SizeOfHeapConfirm   (offsetof(xl_heap_confirm, offnum) + sizeof(OffsetNumber))

Definition at line 305 of file heapam_xlog.h.

◆ SizeOfHeapDelete

#define SizeOfHeapDelete   (offsetof(xl_heap_delete, flags) + sizeof(uint8))

Definition at line 115 of file heapam_xlog.h.

◆ SizeOfHeapFreezePage

#define SizeOfHeapFreezePage   (offsetof(xl_heap_freeze_page, ntuples) + sizeof(uint16))

Definition at line 345 of file heapam_xlog.h.

◆ SizeOfHeapHeader

#define SizeOfHeapHeader   (offsetof(xl_heap_header, t_hoff) + sizeof(uint8))

Definition at line 151 of file heapam_xlog.h.

◆ SizeOfHeapInplace

#define SizeOfHeapInplace   (offsetof(xl_heap_inplace, offnum) + sizeof(OffsetNumber))

Definition at line 314 of file heapam_xlog.h.

◆ SizeOfHeapInsert

#define SizeOfHeapInsert   (offsetof(xl_heap_insert, flags) + sizeof(uint8))

Definition at line 162 of file heapam_xlog.h.

◆ SizeOfHeapLock

#define SizeOfHeapLock   (offsetof(xl_heap_lock, flags) + sizeof(int8))

Definition at line 286 of file heapam_xlog.h.

◆ SizeOfHeapLockUpdated

#define SizeOfHeapLockUpdated   (offsetof(xl_heap_lock_updated, flags) + sizeof(uint8))

Definition at line 297 of file heapam_xlog.h.

◆ SizeOfHeapMultiInsert

#define SizeOfHeapMultiInsert   offsetof(xl_heap_multi_insert, offsets)

Definition at line 182 of file heapam_xlog.h.

◆ SizeOfHeapNewCid

#define SizeOfHeapNewCid   (offsetof(xl_heap_new_cid, target_tid) + sizeof(ItemPointerData))

Definition at line 379 of file heapam_xlog.h.

◆ SizeOfHeapPrune

#define SizeOfHeapPrune   (offsetof(xl_heap_prune, ndead) + sizeof(uint16))

Definition at line 251 of file heapam_xlog.h.

◆ SizeOfHeapTruncate

#define SizeOfHeapTruncate   (offsetof(xl_heap_truncate, relids))

Definition at line 136 of file heapam_xlog.h.

◆ SizeOfHeapUpdate

#define SizeOfHeapUpdate   (offsetof(xl_heap_update, new_offnum) + sizeof(OffsetNumber))

Definition at line 227 of file heapam_xlog.h.

◆ SizeOfHeapVacuum

#define SizeOfHeapVacuum   (offsetof(xl_heap_vacuum, nunused) + sizeof(uint16))

Definition at line 265 of file heapam_xlog.h.

◆ SizeOfHeapVisible

#define SizeOfHeapVisible   (offsetof(xl_heap_visible, flags) + sizeof(uint8))

Definition at line 359 of file heapam_xlog.h.

◆ SizeOfMultiInsertTuple

#define SizeOfMultiInsertTuple   (offsetof(xl_multi_insert_tuple, t_hoff) + sizeof(uint8))

Definition at line 193 of file heapam_xlog.h.

◆ XLH_DELETE_ALL_VISIBLE_CLEARED

#define XLH_DELETE_ALL_VISIBLE_CLEARED   (1<<0)

Definition at line 96 of file heapam_xlog.h.

◆ XLH_DELETE_CONTAINS_OLD

#define XLH_DELETE_CONTAINS_OLD    (XLH_DELETE_CONTAINS_OLD_TUPLE | XLH_DELETE_CONTAINS_OLD_KEY)

Definition at line 103 of file heapam_xlog.h.

◆ XLH_DELETE_CONTAINS_OLD_KEY

#define XLH_DELETE_CONTAINS_OLD_KEY   (1<<2)

Definition at line 98 of file heapam_xlog.h.

◆ XLH_DELETE_CONTAINS_OLD_TUPLE

#define XLH_DELETE_CONTAINS_OLD_TUPLE   (1<<1)

Definition at line 97 of file heapam_xlog.h.

◆ XLH_DELETE_IS_PARTITION_MOVE

#define XLH_DELETE_IS_PARTITION_MOVE   (1<<4)

Definition at line 100 of file heapam_xlog.h.

◆ XLH_DELETE_IS_SUPER

#define XLH_DELETE_IS_SUPER   (1<<3)

Definition at line 99 of file heapam_xlog.h.

◆ XLH_FREEZE_XVAC

#define XLH_FREEZE_XVAC   0x02

Definition at line 321 of file heapam_xlog.h.

◆ XLH_INSERT_ALL_FROZEN_SET

#define XLH_INSERT_ALL_FROZEN_SET   (1<<5)

Definition at line 73 of file heapam_xlog.h.

◆ XLH_INSERT_ALL_VISIBLE_CLEARED

#define XLH_INSERT_ALL_VISIBLE_CLEARED   (1<<0)

Definition at line 66 of file heapam_xlog.h.

◆ XLH_INSERT_CONTAINS_NEW_TUPLE

#define XLH_INSERT_CONTAINS_NEW_TUPLE   (1<<3)

Definition at line 69 of file heapam_xlog.h.

◆ XLH_INSERT_IS_SPECULATIVE

#define XLH_INSERT_IS_SPECULATIVE   (1<<2)

Definition at line 68 of file heapam_xlog.h.

◆ XLH_INSERT_LAST_IN_MULTI

#define XLH_INSERT_LAST_IN_MULTI   (1<<1)

Definition at line 67 of file heapam_xlog.h.

◆ XLH_INSERT_ON_TOAST_RELATION

#define XLH_INSERT_ON_TOAST_RELATION   (1<<4)

Definition at line 70 of file heapam_xlog.h.

◆ XLH_INVALID_XVAC

#define XLH_INVALID_XVAC   0x04

Definition at line 322 of file heapam_xlog.h.

◆ XLH_LOCK_ALL_FROZEN_CLEARED

#define XLH_LOCK_ALL_FROZEN_CLEARED   0x01

Definition at line 275 of file heapam_xlog.h.

◆ XLH_TRUNCATE_CASCADE

#define XLH_TRUNCATE_CASCADE   (1<<0)

Definition at line 120 of file heapam_xlog.h.

◆ XLH_TRUNCATE_RESTART_SEQS

#define XLH_TRUNCATE_RESTART_SEQS   (1<<1)

Definition at line 121 of file heapam_xlog.h.

◆ XLH_UPDATE_CONTAINS_NEW_TUPLE

#define XLH_UPDATE_CONTAINS_NEW_TUPLE   (1<<4)

Definition at line 84 of file heapam_xlog.h.

◆ XLH_UPDATE_CONTAINS_OLD

#define XLH_UPDATE_CONTAINS_OLD    (XLH_UPDATE_CONTAINS_OLD_TUPLE | XLH_UPDATE_CONTAINS_OLD_KEY)

Definition at line 89 of file heapam_xlog.h.

◆ XLH_UPDATE_CONTAINS_OLD_KEY

#define XLH_UPDATE_CONTAINS_OLD_KEY   (1<<3)

Definition at line 83 of file heapam_xlog.h.

◆ XLH_UPDATE_CONTAINS_OLD_TUPLE

#define XLH_UPDATE_CONTAINS_OLD_TUPLE   (1<<2)

Definition at line 82 of file heapam_xlog.h.

◆ XLH_UPDATE_NEW_ALL_VISIBLE_CLEARED

#define XLH_UPDATE_NEW_ALL_VISIBLE_CLEARED   (1<<1)

Definition at line 81 of file heapam_xlog.h.

◆ XLH_UPDATE_OLD_ALL_VISIBLE_CLEARED

#define XLH_UPDATE_OLD_ALL_VISIBLE_CLEARED   (1<<0)

Definition at line 79 of file heapam_xlog.h.

◆ XLH_UPDATE_PREFIX_FROM_OLD

#define XLH_UPDATE_PREFIX_FROM_OLD   (1<<5)

Definition at line 85 of file heapam_xlog.h.

◆ XLH_UPDATE_SUFFIX_FROM_OLD

#define XLH_UPDATE_SUFFIX_FROM_OLD   (1<<6)

Definition at line 86 of file heapam_xlog.h.

◆ XLHL_KEYS_UPDATED

#define XLHL_KEYS_UPDATED   0x10

Definition at line 272 of file heapam_xlog.h.

◆ XLHL_XMAX_EXCL_LOCK

#define XLHL_XMAX_EXCL_LOCK   0x04

Definition at line 270 of file heapam_xlog.h.

◆ XLHL_XMAX_IS_MULTI

#define XLHL_XMAX_IS_MULTI   0x01

Definition at line 268 of file heapam_xlog.h.

◆ XLHL_XMAX_KEYSHR_LOCK

#define XLHL_XMAX_KEYSHR_LOCK   0x08

Definition at line 271 of file heapam_xlog.h.

◆ XLHL_XMAX_LOCK_ONLY

#define XLHL_XMAX_LOCK_ONLY   0x02

Definition at line 269 of file heapam_xlog.h.

◆ XLOG_HEAP2_FREEZE_PAGE

#define XLOG_HEAP2_FREEZE_PAGE   0x30

Definition at line 56 of file heapam_xlog.h.

◆ XLOG_HEAP2_LOCK_UPDATED

#define XLOG_HEAP2_LOCK_UPDATED   0x60

Definition at line 59 of file heapam_xlog.h.

◆ XLOG_HEAP2_MULTI_INSERT

#define XLOG_HEAP2_MULTI_INSERT   0x50

Definition at line 58 of file heapam_xlog.h.

◆ XLOG_HEAP2_NEW_CID

#define XLOG_HEAP2_NEW_CID   0x70

Definition at line 60 of file heapam_xlog.h.

◆ XLOG_HEAP2_PRUNE

#define XLOG_HEAP2_PRUNE   0x10

Definition at line 54 of file heapam_xlog.h.

◆ XLOG_HEAP2_REWRITE

#define XLOG_HEAP2_REWRITE   0x00

Definition at line 53 of file heapam_xlog.h.

◆ XLOG_HEAP2_VACUUM

#define XLOG_HEAP2_VACUUM   0x20

Definition at line 55 of file heapam_xlog.h.

◆ XLOG_HEAP2_VISIBLE

#define XLOG_HEAP2_VISIBLE   0x40

Definition at line 57 of file heapam_xlog.h.

◆ XLOG_HEAP_CONFIRM

#define XLOG_HEAP_CONFIRM   0x50

Definition at line 37 of file heapam_xlog.h.

◆ XLOG_HEAP_DELETE

#define XLOG_HEAP_DELETE   0x10

Definition at line 33 of file heapam_xlog.h.

◆ XLOG_HEAP_HOT_UPDATE

#define XLOG_HEAP_HOT_UPDATE   0x40

Definition at line 36 of file heapam_xlog.h.

◆ XLOG_HEAP_INIT_PAGE

#define XLOG_HEAP_INIT_PAGE   0x80

Definition at line 46 of file heapam_xlog.h.

◆ XLOG_HEAP_INPLACE

#define XLOG_HEAP_INPLACE   0x70

Definition at line 39 of file heapam_xlog.h.

◆ XLOG_HEAP_INSERT

#define XLOG_HEAP_INSERT   0x00

Definition at line 32 of file heapam_xlog.h.

◆ XLOG_HEAP_LOCK

#define XLOG_HEAP_LOCK   0x60

Definition at line 38 of file heapam_xlog.h.

◆ XLOG_HEAP_OPMASK

#define XLOG_HEAP_OPMASK   0x70

Definition at line 41 of file heapam_xlog.h.

◆ XLOG_HEAP_TRUNCATE

#define XLOG_HEAP_TRUNCATE   0x30

Definition at line 35 of file heapam_xlog.h.

◆ XLOG_HEAP_UPDATE

#define XLOG_HEAP_UPDATE   0x20

Definition at line 34 of file heapam_xlog.h.

Typedef Documentation

◆ xl_heap_confirm

◆ xl_heap_delete

◆ xl_heap_freeze_page

◆ xl_heap_freeze_tuple

◆ xl_heap_header

◆ xl_heap_inplace

◆ xl_heap_insert

◆ xl_heap_lock

typedef struct xl_heap_lock xl_heap_lock

◆ xl_heap_lock_updated

◆ xl_heap_multi_insert

◆ xl_heap_new_cid

◆ xl_heap_prune

typedef struct xl_heap_prune xl_heap_prune

◆ xl_heap_rewrite_mapping

◆ xl_heap_truncate

◆ xl_heap_update

◆ xl_heap_vacuum

◆ xl_heap_visible

◆ xl_multi_insert_tuple

Function Documentation

◆ heap2_desc()

void heap2_desc ( StringInfo  buf,
XLogReaderState record 
)

Definition at line 118 of file heapdesc.c.

119 {
120  char *rec = XLogRecGetData(record);
121  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
122 
123  info &= XLOG_HEAP_OPMASK;
124  if (info == XLOG_HEAP2_PRUNE)
125  {
126  xl_heap_prune *xlrec = (xl_heap_prune *) rec;
127 
128  appendStringInfo(buf, "latestRemovedXid %u nredirected %u ndead %u",
129  xlrec->latestRemovedXid,
130  xlrec->nredirected,
131  xlrec->ndead);
132  }
133  else if (info == XLOG_HEAP2_VACUUM)
134  {
135  xl_heap_vacuum *xlrec = (xl_heap_vacuum *) rec;
136 
137  appendStringInfo(buf, "nunused %u", xlrec->nunused);
138  }
139  else if (info == XLOG_HEAP2_FREEZE_PAGE)
140  {
141  xl_heap_freeze_page *xlrec = (xl_heap_freeze_page *) rec;
142 
143  appendStringInfo(buf, "cutoff xid %u ntuples %u",
144  xlrec->cutoff_xid, xlrec->ntuples);
145  }
146  else if (info == XLOG_HEAP2_VISIBLE)
147  {
148  xl_heap_visible *xlrec = (xl_heap_visible *) rec;
149 
150  appendStringInfo(buf, "cutoff xid %u flags 0x%02X",
151  xlrec->cutoff_xid, xlrec->flags);
152  }
153  else if (info == XLOG_HEAP2_MULTI_INSERT)
154  {
156 
157  appendStringInfo(buf, "%d tuples flags 0x%02X", xlrec->ntuples,
158  xlrec->flags);
159  }
160  else if (info == XLOG_HEAP2_LOCK_UPDATED)
161  {
163 
164  appendStringInfo(buf, "off %u: xmax %u: flags 0x%02X ",
165  xlrec->offnum, xlrec->xmax, xlrec->flags);
166  out_infobits(buf, xlrec->infobits_set);
167  }
168  else if (info == XLOG_HEAP2_NEW_CID)
169  {
170  xl_heap_new_cid *xlrec = (xl_heap_new_cid *) rec;
171 
172  appendStringInfo(buf, "rel %u/%u/%u; tid %u/%u",
173  xlrec->target_node.spcNode,
174  xlrec->target_node.dbNode,
175  xlrec->target_node.relNode,
178  appendStringInfo(buf, "; cmin: %u, cmax: %u, combo: %u",
179  xlrec->cmin, xlrec->cmax, xlrec->combocid);
180  }
181 }
unsigned char uint8
Definition: c.h:439
#define XLOG_HEAP2_PRUNE
Definition: heapam_xlog.h:54
#define XLOG_HEAP2_MULTI_INSERT
Definition: heapam_xlog.h:58
#define XLOG_HEAP2_VACUUM
Definition: heapam_xlog.h:55
#define XLOG_HEAP_OPMASK
Definition: heapam_xlog.h:41
#define XLOG_HEAP2_LOCK_UPDATED
Definition: heapam_xlog.h:59
#define XLOG_HEAP2_FREEZE_PAGE
Definition: heapam_xlog.h:56
#define XLOG_HEAP2_NEW_CID
Definition: heapam_xlog.h:60
#define XLOG_HEAP2_VISIBLE
Definition: heapam_xlog.h:57
static void out_infobits(StringInfo buf, uint8 infobits)
Definition: heapdesc.c:20
#define ItemPointerGetBlockNumber(pointer)
Definition: itemptr.h:98
#define ItemPointerGetOffsetNumber(pointer)
Definition: itemptr.h:117
static char * buf
Definition: pg_test_fsync.c:67
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:91
TransactionId cutoff_xid
Definition: heapam_xlog.h:341
TransactionId xmax
Definition: heapam_xlog.h:291
OffsetNumber offnum
Definition: heapam_xlog.h:292
CommandId cmin
Definition: heapam_xlog.h:368
CommandId combocid
Definition: heapam_xlog.h:370
RelFileNode target_node
Definition: heapam_xlog.h:375
ItemPointerData target_tid
Definition: heapam_xlog.h:376
CommandId cmax
Definition: heapam_xlog.h:369
TransactionId latestRemovedXid
Definition: heapam_xlog.h:245
uint16 nredirected
Definition: heapam_xlog.h:246
TransactionId cutoff_xid
Definition: heapam_xlog.h:355
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:408
#define XLogRecGetData(decoder)
Definition: xlogreader.h:413
#define XLR_INFO_MASK
Definition: xlogrecord.h:62

References appendStringInfo(), buf, xl_heap_new_cid::cmax, xl_heap_new_cid::cmin, xl_heap_new_cid::combocid, xl_heap_freeze_page::cutoff_xid, xl_heap_visible::cutoff_xid, RelFileNode::dbNode, xl_heap_multi_insert::flags, xl_heap_lock_updated::flags, xl_heap_visible::flags, xl_heap_lock_updated::infobits_set, ItemPointerGetBlockNumber, ItemPointerGetOffsetNumber, xl_heap_prune::latestRemovedXid, xl_heap_prune::ndead, xl_heap_prune::nredirected, xl_heap_multi_insert::ntuples, xl_heap_freeze_page::ntuples, xl_heap_vacuum::nunused, xl_heap_lock_updated::offnum, out_infobits(), RelFileNode::relNode, RelFileNode::spcNode, xl_heap_new_cid::target_node, xl_heap_new_cid::target_tid, XLOG_HEAP2_FREEZE_PAGE, XLOG_HEAP2_LOCK_UPDATED, XLOG_HEAP2_MULTI_INSERT, XLOG_HEAP2_NEW_CID, XLOG_HEAP2_PRUNE, XLOG_HEAP2_VACUUM, XLOG_HEAP2_VISIBLE, XLOG_HEAP_OPMASK, XLogRecGetData, XLogRecGetInfo, XLR_INFO_MASK, and xl_heap_lock_updated::xmax.

◆ heap2_identify()

const char* heap2_identify ( uint8  info)

Definition at line 229 of file heapdesc.c.

230 {
231  const char *id = NULL;
232 
233  switch (info & ~XLR_INFO_MASK)
234  {
235  case XLOG_HEAP2_PRUNE:
236  id = "PRUNE";
237  break;
238  case XLOG_HEAP2_VACUUM:
239  id = "VACUUM";
240  break;
242  id = "FREEZE_PAGE";
243  break;
244  case XLOG_HEAP2_VISIBLE:
245  id = "VISIBLE";
246  break;
248  id = "MULTI_INSERT";
249  break;
251  id = "MULTI_INSERT+INIT";
252  break;
254  id = "LOCK_UPDATED";
255  break;
256  case XLOG_HEAP2_NEW_CID:
257  id = "NEW_CID";
258  break;
259  case XLOG_HEAP2_REWRITE:
260  id = "REWRITE";
261  break;
262  }
263 
264  return id;
265 }
#define XLOG_HEAP2_REWRITE
Definition: heapam_xlog.h:53
#define XLOG_HEAP_INIT_PAGE
Definition: heapam_xlog.h:46

References XLOG_HEAP2_FREEZE_PAGE, XLOG_HEAP2_LOCK_UPDATED, XLOG_HEAP2_MULTI_INSERT, XLOG_HEAP2_NEW_CID, XLOG_HEAP2_PRUNE, XLOG_HEAP2_REWRITE, XLOG_HEAP2_VACUUM, XLOG_HEAP2_VISIBLE, XLOG_HEAP_INIT_PAGE, and XLR_INFO_MASK.

◆ heap2_redo()

void heap2_redo ( XLogReaderState record)

Definition at line 9867 of file heapam.c.

9868 {
9869  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
9870 
9871  switch (info & XLOG_HEAP_OPMASK)
9872  {
9873  case XLOG_HEAP2_PRUNE:
9874  heap_xlog_prune(record);
9875  break;
9876  case XLOG_HEAP2_VACUUM:
9877  heap_xlog_vacuum(record);
9878  break;
9880  heap_xlog_freeze_page(record);
9881  break;
9882  case XLOG_HEAP2_VISIBLE:
9883  heap_xlog_visible(record);
9884  break;
9886  heap_xlog_multi_insert(record);
9887  break;
9889  heap_xlog_lock_updated(record);
9890  break;
9891  case XLOG_HEAP2_NEW_CID:
9892 
9893  /*
9894  * Nothing to do on a real replay, only used during logical
9895  * decoding.
9896  */
9897  break;
9898  case XLOG_HEAP2_REWRITE:
9899  heap_xlog_logical_rewrite(record);
9900  break;
9901  default:
9902  elog(PANIC, "heap2_redo: unknown op code %u", info);
9903  }
9904 }
#define PANIC
Definition: elog.h:36
#define elog(elevel,...)
Definition: elog.h:218
static void heap_xlog_prune(XLogReaderState *record)
Definition: heapam.c:8621
static void heap_xlog_vacuum(XLogReaderState *record)
Definition: heapam.c:8707
static void heap_xlog_lock_updated(XLogReaderState *record)
Definition: heapam.c:9720
static void heap_xlog_multi_insert(XLogReaderState *record)
Definition: heapam.c:9194
static void heap_xlog_visible(XLogReaderState *record)
Definition: heapam.c:8782
static void heap_xlog_freeze_page(XLogReaderState *record)
Definition: heapam.c:8922
void heap_xlog_logical_rewrite(XLogReaderState *r)
Definition: rewriteheap.c:1110

References elog, heap_xlog_freeze_page(), heap_xlog_lock_updated(), heap_xlog_logical_rewrite(), heap_xlog_multi_insert(), heap_xlog_prune(), heap_xlog_vacuum(), heap_xlog_visible(), PANIC, XLOG_HEAP2_FREEZE_PAGE, XLOG_HEAP2_LOCK_UPDATED, XLOG_HEAP2_MULTI_INSERT, XLOG_HEAP2_NEW_CID, XLOG_HEAP2_PRUNE, XLOG_HEAP2_REWRITE, XLOG_HEAP2_VACUUM, XLOG_HEAP2_VISIBLE, XLOG_HEAP_OPMASK, XLogRecGetInfo, and XLR_INFO_MASK.

◆ heap_desc()

void heap_desc ( StringInfo  buf,
XLogReaderState record 
)

Definition at line 35 of file heapdesc.c.

36 {
37  char *rec = XLogRecGetData(record);
38  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
39 
40  info &= XLOG_HEAP_OPMASK;
41  if (info == XLOG_HEAP_INSERT)
42  {
43  xl_heap_insert *xlrec = (xl_heap_insert *) rec;
44 
45  appendStringInfo(buf, "off %u flags 0x%02X", xlrec->offnum,
46  xlrec->flags);
47  }
48  else if (info == XLOG_HEAP_DELETE)
49  {
50  xl_heap_delete *xlrec = (xl_heap_delete *) rec;
51 
52  appendStringInfo(buf, "off %u flags 0x%02X ",
53  xlrec->offnum,
54  xlrec->flags);
55  out_infobits(buf, xlrec->infobits_set);
56  }
57  else if (info == XLOG_HEAP_UPDATE)
58  {
59  xl_heap_update *xlrec = (xl_heap_update *) rec;
60 
61  appendStringInfo(buf, "off %u xmax %u flags 0x%02X ",
62  xlrec->old_offnum,
63  xlrec->old_xmax,
64  xlrec->flags);
66  appendStringInfo(buf, "; new off %u xmax %u",
67  xlrec->new_offnum,
68  xlrec->new_xmax);
69  }
70  else if (info == XLOG_HEAP_HOT_UPDATE)
71  {
72  xl_heap_update *xlrec = (xl_heap_update *) rec;
73 
74  appendStringInfo(buf, "off %u xmax %u flags 0x%02X ",
75  xlrec->old_offnum,
76  xlrec->old_xmax,
77  xlrec->flags);
79  appendStringInfo(buf, "; new off %u xmax %u",
80  xlrec->new_offnum,
81  xlrec->new_xmax);
82  }
83  else if (info == XLOG_HEAP_TRUNCATE)
84  {
85  xl_heap_truncate *xlrec = (xl_heap_truncate *) rec;
86  int i;
87 
88  if (xlrec->flags & XLH_TRUNCATE_CASCADE)
89  appendStringInfoString(buf, "cascade ");
90  if (xlrec->flags & XLH_TRUNCATE_RESTART_SEQS)
91  appendStringInfoString(buf, "restart_seqs ");
92  appendStringInfo(buf, "nrelids %u relids", xlrec->nrelids);
93  for (i = 0; i < xlrec->nrelids; i++)
94  appendStringInfo(buf, " %u", xlrec->relids[i]);
95  }
96  else if (info == XLOG_HEAP_CONFIRM)
97  {
98  xl_heap_confirm *xlrec = (xl_heap_confirm *) rec;
99 
100  appendStringInfo(buf, "off %u", xlrec->offnum);
101  }
102  else if (info == XLOG_HEAP_LOCK)
103  {
104  xl_heap_lock *xlrec = (xl_heap_lock *) rec;
105 
106  appendStringInfo(buf, "off %u: xid %u: flags 0x%02X ",
107  xlrec->offnum, xlrec->locking_xid, xlrec->flags);
108  out_infobits(buf, xlrec->infobits_set);
109  }
110  else if (info == XLOG_HEAP_INPLACE)
111  {
112  xl_heap_inplace *xlrec = (xl_heap_inplace *) rec;
113 
114  appendStringInfo(buf, "off %u", xlrec->offnum);
115  }
116 }
#define XLOG_HEAP_HOT_UPDATE
Definition: heapam_xlog.h:36
#define XLOG_HEAP_DELETE
Definition: heapam_xlog.h:33
#define XLOG_HEAP_TRUNCATE
Definition: heapam_xlog.h:35
#define XLH_TRUNCATE_RESTART_SEQS
Definition: heapam_xlog.h:121
#define XLOG_HEAP_UPDATE
Definition: heapam_xlog.h:34
#define XLOG_HEAP_INPLACE
Definition: heapam_xlog.h:39
#define XLOG_HEAP_LOCK
Definition: heapam_xlog.h:38
#define XLH_TRUNCATE_CASCADE
Definition: heapam_xlog.h:120
#define XLOG_HEAP_INSERT
Definition: heapam_xlog.h:32
#define XLOG_HEAP_CONFIRM
Definition: heapam_xlog.h:37
int i
Definition: isn.c:73
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:176
OffsetNumber offnum
Definition: heapam_xlog.h:302
OffsetNumber offnum
Definition: heapam_xlog.h:110
uint8 infobits_set
Definition: heapam_xlog.h:111
OffsetNumber offnum
Definition: heapam_xlog.h:310
OffsetNumber offnum
Definition: heapam_xlog.h:156
OffsetNumber offnum
Definition: heapam_xlog.h:281
int8 infobits_set
Definition: heapam_xlog.h:282
TransactionId locking_xid
Definition: heapam_xlog.h:280
Oid relids[FLEXIBLE_ARRAY_MEMBER]
Definition: heapam_xlog.h:133
TransactionId new_xmax
Definition: heapam_xlog.h:218
uint8 old_infobits_set
Definition: heapam_xlog.h:216
TransactionId old_xmax
Definition: heapam_xlog.h:214
OffsetNumber old_offnum
Definition: heapam_xlog.h:215
OffsetNumber new_offnum
Definition: heapam_xlog.h:219

References appendStringInfo(), appendStringInfoString(), buf, xl_heap_delete::flags, xl_heap_truncate::flags, xl_heap_insert::flags, xl_heap_update::flags, xl_heap_lock::flags, i, xl_heap_delete::infobits_set, xl_heap_lock::infobits_set, xl_heap_lock::locking_xid, xl_heap_update::new_offnum, xl_heap_update::new_xmax, xl_heap_truncate::nrelids, xl_heap_delete::offnum, xl_heap_insert::offnum, xl_heap_lock::offnum, xl_heap_confirm::offnum, xl_heap_inplace::offnum, xl_heap_update::old_infobits_set, xl_heap_update::old_offnum, xl_heap_update::old_xmax, out_infobits(), xl_heap_truncate::relids, XLH_TRUNCATE_CASCADE, XLH_TRUNCATE_RESTART_SEQS, XLOG_HEAP_CONFIRM, XLOG_HEAP_DELETE, XLOG_HEAP_HOT_UPDATE, XLOG_HEAP_INPLACE, XLOG_HEAP_INSERT, XLOG_HEAP_LOCK, XLOG_HEAP_OPMASK, XLOG_HEAP_TRUNCATE, XLOG_HEAP_UPDATE, XLogRecGetData, XLogRecGetInfo, and XLR_INFO_MASK.

◆ heap_execute_freeze_tuple()

void heap_execute_freeze_tuple ( HeapTupleHeader  tuple,
xl_heap_freeze_tuple xlrec_tp 
)

Definition at line 6760 of file heapam.c.

6761 {
6762  HeapTupleHeaderSetXmax(tuple, frz->xmax);
6763 
6764  if (frz->frzflags & XLH_FREEZE_XVAC)
6766 
6767  if (frz->frzflags & XLH_INVALID_XVAC)
6769 
6770  tuple->t_infomask = frz->t_infomask;
6771  tuple->t_infomask2 = frz->t_infomask2;
6772 }
#define XLH_INVALID_XVAC
Definition: heapam_xlog.h:322
#define XLH_FREEZE_XVAC
Definition: heapam_xlog.h:321
#define HeapTupleHeaderSetXmax(tup, xid)
Definition: htup_details.h:375
#define HeapTupleHeaderSetXvac(tup, xid)
Definition: htup_details.h:418
#define FrozenTransactionId
Definition: transam.h:33
#define InvalidTransactionId
Definition: transam.h:31

References FrozenTransactionId, xl_heap_freeze_tuple::frzflags, HeapTupleHeaderSetXmax, HeapTupleHeaderSetXvac, InvalidTransactionId, xl_heap_freeze_tuple::t_infomask, HeapTupleHeaderData::t_infomask, xl_heap_freeze_tuple::t_infomask2, HeapTupleHeaderData::t_infomask2, XLH_FREEZE_XVAC, XLH_INVALID_XVAC, and xl_heap_freeze_tuple::xmax.

Referenced by heap_freeze_tuple(), heap_xlog_freeze_page(), and lazy_scan_prune().

◆ heap_identify()

const char* heap_identify ( uint8  info)

Definition at line 184 of file heapdesc.c.

185 {
186  const char *id = NULL;
187 
188  switch (info & ~XLR_INFO_MASK)
189  {
190  case XLOG_HEAP_INSERT:
191  id = "INSERT";
192  break;
194  id = "INSERT+INIT";
195  break;
196  case XLOG_HEAP_DELETE:
197  id = "DELETE";
198  break;
199  case XLOG_HEAP_UPDATE:
200  id = "UPDATE";
201  break;
203  id = "UPDATE+INIT";
204  break;
206  id = "HOT_UPDATE";
207  break;
209  id = "HOT_UPDATE+INIT";
210  break;
211  case XLOG_HEAP_TRUNCATE:
212  id = "TRUNCATE";
213  break;
214  case XLOG_HEAP_CONFIRM:
215  id = "HEAP_CONFIRM";
216  break;
217  case XLOG_HEAP_LOCK:
218  id = "LOCK";
219  break;
220  case XLOG_HEAP_INPLACE:
221  id = "INPLACE";
222  break;
223  }
224 
225  return id;
226 }

References XLOG_HEAP_CONFIRM, XLOG_HEAP_DELETE, XLOG_HEAP_HOT_UPDATE, XLOG_HEAP_INIT_PAGE, XLOG_HEAP_INPLACE, XLOG_HEAP_INSERT, XLOG_HEAP_LOCK, XLOG_HEAP_TRUNCATE, XLOG_HEAP_UPDATE, and XLR_INFO_MASK.

◆ heap_mask()

void heap_mask ( char *  pagedata,
BlockNumber  blkno 
)

Definition at line 9910 of file heapam.c.

9911 {
9912  Page page = (Page) pagedata;
9913  OffsetNumber off;
9914 
9916 
9917  mask_page_hint_bits(page);
9918  mask_unused_space(page);
9919 
9920  for (off = 1; off <= PageGetMaxOffsetNumber(page); off++)
9921  {
9922  ItemId iid = PageGetItemId(page, off);
9923  char *page_item;
9924 
9925  page_item = (char *) (page + ItemIdGetOffset(iid));
9926 
9927  if (ItemIdIsNormal(iid))
9928  {
9929  HeapTupleHeader page_htup = (HeapTupleHeader) page_item;
9930 
9931  /*
9932  * If xmin of a tuple is not yet frozen, we should ignore
9933  * differences in hint bits, since they can be set without
9934  * emitting WAL.
9935  */
9936  if (!HeapTupleHeaderXminFrozen(page_htup))
9937  page_htup->t_infomask &= ~HEAP_XACT_MASK;
9938  else
9939  {
9940  /* Still we need to mask xmax hint bits. */
9941  page_htup->t_infomask &= ~HEAP_XMAX_INVALID;
9942  page_htup->t_infomask &= ~HEAP_XMAX_COMMITTED;
9943  }
9944 
9945  /*
9946  * During replay, we set Command Id to FirstCommandId. Hence, mask
9947  * it. See heap_xlog_insert() for details.
9948  */
9949  page_htup->t_choice.t_heap.t_field3.t_cid = MASK_MARKER;
9950 
9951  /*
9952  * For a speculative tuple, heap_insert() does not set ctid in the
9953  * caller-passed heap tuple itself, leaving the ctid field to
9954  * contain a speculative token value - a per-backend monotonically
9955  * increasing identifier. Besides, it does not WAL-log ctid under
9956  * any circumstances.
9957  *
9958  * During redo, heap_xlog_insert() sets t_ctid to current block
9959  * number and self offset number. It doesn't care about any
9960  * speculative insertions on the primary. Hence, we set t_ctid to
9961  * current block number and self offset number to ignore any
9962  * inconsistency.
9963  */
9964  if (HeapTupleHeaderIsSpeculative(page_htup))
9965  ItemPointerSet(&page_htup->t_ctid, blkno, off);
9966 
9967  /*
9968  * NB: Not ignoring ctid changes due to the tuple having moved
9969  * (i.e. HeapTupleHeaderIndicatesMovedPartitions), because that's
9970  * important information that needs to be in-sync between primary
9971  * and standby, and thus is WAL logged.
9972  */
9973  }
9974 
9975  /*
9976  * Ignore any padding bytes after the tuple, when the length of the
9977  * item is not MAXALIGNed.
9978  */
9979  if (ItemIdHasStorage(iid))
9980  {
9981  int len = ItemIdGetLength(iid);
9982  int padlen = MAXALIGN(len) - len;
9983 
9984  if (padlen > 0)
9985  memset(page_item + len, MASK_MARKER, padlen);
9986  }
9987  }
9988 }
void mask_page_lsn_and_checksum(Page page)
Definition: bufmask.c:31
void mask_unused_space(Page page)
Definition: bufmask.c:71
void mask_page_hint_bits(Page page)
Definition: bufmask.c:46
#define MASK_MARKER
Definition: bufmask.h:24
Pointer Page
Definition: bufpage.h:78
#define PageGetMaxOffsetNumber(page)
Definition: bufpage.h:356
#define PageGetItemId(page, offsetNumber)
Definition: bufpage.h:234
#define MAXALIGN(LEN)
Definition: c.h:757
HeapTupleHeaderData * HeapTupleHeader
Definition: htup.h:23
#define HEAP_XMAX_COMMITTED
Definition: htup_details.h:206
#define HEAP_XACT_MASK
Definition: htup_details.h:214
#define HeapTupleHeaderXminFrozen(tup)
Definition: htup_details.h:330
#define HEAP_XMAX_INVALID
Definition: htup_details.h:207
#define HeapTupleHeaderIsSpeculative(tup)
Definition: htup_details.h:424
#define ItemIdGetLength(itemId)
Definition: itemid.h:59
#define ItemIdIsNormal(itemId)
Definition: itemid.h:99
#define ItemIdGetOffset(itemId)
Definition: itemid.h:65
#define ItemIdHasStorage(itemId)
Definition: itemid.h:120
#define ItemPointerSet(pointer, blockNumber, offNum)
Definition: itemptr.h:127
uint16 OffsetNumber
Definition: off.h:24
const void size_t len
union HeapTupleFields::@45 t_field3
CommandId t_cid
Definition: htup_details.h:128
union HeapTupleHeaderData::@46 t_choice
ItemPointerData t_ctid
Definition: htup_details.h:160
HeapTupleFields t_heap
Definition: htup_details.h:156

References HEAP_XACT_MASK, HEAP_XMAX_COMMITTED, HEAP_XMAX_INVALID, HeapTupleHeaderIsSpeculative, HeapTupleHeaderXminFrozen, ItemIdGetLength, ItemIdGetOffset, ItemIdHasStorage, ItemIdIsNormal, ItemPointerSet, len, MASK_MARKER, mask_page_hint_bits(), mask_page_lsn_and_checksum(), mask_unused_space(), MAXALIGN, PageGetItemId, PageGetMaxOffsetNumber, and HeapTupleHeaderData::t_infomask.

◆ heap_prepare_freeze_tuple()

bool heap_prepare_freeze_tuple ( HeapTupleHeader  tuple,
TransactionId  relfrozenxid,
TransactionId  relminmxid,
TransactionId  cutoff_xid,
TransactionId  cutoff_multi,
xl_heap_freeze_tuple frz,
bool totally_frozen,
TransactionId relfrozenxid_out,
MultiXactId relminmxid_out 
)

Definition at line 6463 of file heapam.c.

6469 {
6470  bool changed = false;
6471  bool xmax_already_frozen = false;
6472  bool xmin_frozen;
6473  bool freeze_xmax;
6474  TransactionId xid;
6475 
6476  frz->frzflags = 0;
6477  frz->t_infomask2 = tuple->t_infomask2;
6478  frz->t_infomask = tuple->t_infomask;
6479  frz->xmax = HeapTupleHeaderGetRawXmax(tuple);
6480 
6481  /*
6482  * Process xmin. xmin_frozen has two slightly different meanings: in the
6483  * !XidIsNormal case, it means "the xmin doesn't need any freezing" (it's
6484  * already a permanent value), while in the block below it is set true to
6485  * mean "xmin won't need freezing after what we do to it here" (false
6486  * otherwise). In both cases we're allowed to set totally_frozen, as far
6487  * as xmin is concerned. Both cases also don't require relfrozenxid_out
6488  * handling, since either way the tuple's xmin will be a permanent value
6489  * once we're done with it.
6490  */
6491  xid = HeapTupleHeaderGetXmin(tuple);
6492  if (!TransactionIdIsNormal(xid))
6493  xmin_frozen = true;
6494  else
6495  {
6496  if (TransactionIdPrecedes(xid, relfrozenxid))
6497  ereport(ERROR,
6499  errmsg_internal("found xmin %u from before relfrozenxid %u",
6500  xid, relfrozenxid)));
6501 
6502  xmin_frozen = TransactionIdPrecedes(xid, cutoff_xid);
6503  if (xmin_frozen)
6504  {
6505  if (!TransactionIdDidCommit(xid))
6506  ereport(ERROR,
6508  errmsg_internal("uncommitted xmin %u from before xid cutoff %u needs to be frozen",
6509  xid, cutoff_xid)));
6510 
6511  frz->t_infomask |= HEAP_XMIN_FROZEN;
6512  changed = true;
6513  }
6514  else
6515  {
6516  /* xmin to remain unfrozen. Could push back relfrozenxid_out. */
6517  if (TransactionIdPrecedes(xid, *relfrozenxid_out))
6518  *relfrozenxid_out = xid;
6519  }
6520  }
6521 
6522  /*
6523  * Process xmax. To thoroughly examine the current Xmax value we need to
6524  * resolve a MultiXactId to its member Xids, in case some of them are
6525  * below the given cutoff for Xids. In that case, those values might need
6526  * freezing, too. Also, if a multi needs freezing, we cannot simply take
6527  * it out --- if there's a live updater Xid, it needs to be kept.
6528  *
6529  * Make sure to keep heap_tuple_would_freeze in sync with this.
6530  */
6531  xid = HeapTupleHeaderGetRawXmax(tuple);
6532 
6533  if (tuple->t_infomask & HEAP_XMAX_IS_MULTI)
6534  {
6535  TransactionId newxmax;
6536  uint16 flags;
6537  TransactionId mxid_oldest_xid_out = *relfrozenxid_out;
6538 
6539  newxmax = FreezeMultiXactId(xid, tuple->t_infomask,
6540  relfrozenxid, relminmxid,
6541  cutoff_xid, cutoff_multi,
6542  &flags, &mxid_oldest_xid_out);
6543 
6544  freeze_xmax = (flags & FRM_INVALIDATE_XMAX);
6545 
6546  if (flags & FRM_RETURN_IS_XID)
6547  {
6548  /*
6549  * xmax will become an updater Xid (original MultiXact's updater
6550  * member Xid will be carried forward as a simple Xid in Xmax).
6551  * Might have to ratchet back relfrozenxid_out here, though never
6552  * relminmxid_out.
6553  */
6554  Assert(!freeze_xmax);
6555  Assert(TransactionIdIsValid(newxmax));
6556  if (TransactionIdPrecedes(newxmax, *relfrozenxid_out))
6557  *relfrozenxid_out = newxmax;
6558 
6559  /*
6560  * NB -- some of these transformations are only valid because we
6561  * know the return Xid is a tuple updater (i.e. not merely a
6562  * locker.) Also note that the only reason we don't explicitly
6563  * worry about HEAP_KEYS_UPDATED is because it lives in
6564  * t_infomask2 rather than t_infomask.
6565  */
6566  frz->t_infomask &= ~HEAP_XMAX_BITS;
6567  frz->xmax = newxmax;
6568  if (flags & FRM_MARK_COMMITTED)
6570  changed = true;
6571  }
6572  else if (flags & FRM_RETURN_IS_MULTI)
6573  {
6574  uint16 newbits;
6575  uint16 newbits2;
6576 
6577  /*
6578  * xmax is an old MultiXactId that we have to replace with a new
6579  * MultiXactId, to carry forward two or more original member XIDs.
6580  * Might have to ratchet back relfrozenxid_out here, though never
6581  * relminmxid_out.
6582  */
6583  Assert(!freeze_xmax);
6584  Assert(MultiXactIdIsValid(newxmax));
6585  Assert(!MultiXactIdPrecedes(newxmax, *relminmxid_out));
6586  Assert(TransactionIdPrecedesOrEquals(mxid_oldest_xid_out,
6587  *relfrozenxid_out));
6588  *relfrozenxid_out = mxid_oldest_xid_out;
6589 
6590  /*
6591  * We can't use GetMultiXactIdHintBits directly on the new multi
6592  * here; that routine initializes the masks to all zeroes, which
6593  * would lose other bits we need. Doing it this way ensures all
6594  * unrelated bits remain untouched.
6595  */
6596  frz->t_infomask &= ~HEAP_XMAX_BITS;
6597  frz->t_infomask2 &= ~HEAP_KEYS_UPDATED;
6598  GetMultiXactIdHintBits(newxmax, &newbits, &newbits2);
6599  frz->t_infomask |= newbits;
6600  frz->t_infomask2 |= newbits2;
6601 
6602  frz->xmax = newxmax;
6603 
6604  changed = true;
6605  }
6606  else if (flags & FRM_NOOP)
6607  {
6608  /*
6609  * xmax is a MultiXactId, and nothing about it changes for now.
6610  * Might have to ratchet back relminmxid_out, relfrozenxid_out, or
6611  * both together.
6612  */
6613  Assert(!freeze_xmax);
6614  Assert(MultiXactIdIsValid(newxmax) && xid == newxmax);
6615  Assert(TransactionIdPrecedesOrEquals(mxid_oldest_xid_out,
6616  *relfrozenxid_out));
6617  if (MultiXactIdPrecedes(xid, *relminmxid_out))
6618  *relminmxid_out = xid;
6619  *relfrozenxid_out = mxid_oldest_xid_out;
6620  }
6621  else
6622  {
6623  /*
6624  * Keeping nothing (neither an Xid nor a MultiXactId) in xmax.
6625  * Won't have to ratchet back relminmxid_out or relfrozenxid_out.
6626  */
6627  Assert(freeze_xmax);
6628  Assert(!TransactionIdIsValid(newxmax));
6629  }
6630  }
6631  else if (TransactionIdIsNormal(xid))
6632  {
6633  if (TransactionIdPrecedes(xid, relfrozenxid))
6634  ereport(ERROR,
6636  errmsg_internal("found xmax %u from before relfrozenxid %u",
6637  xid, relfrozenxid)));
6638 
6639  if (TransactionIdPrecedes(xid, cutoff_xid))
6640  {
6641  /*
6642  * If we freeze xmax, make absolutely sure that it's not an XID
6643  * that is important. (Note, a lock-only xmax can be removed
6644  * independent of committedness, since a committed lock holder has
6645  * released the lock).
6646  */
6647  if (!HEAP_XMAX_IS_LOCKED_ONLY(tuple->t_infomask) &&
6649  ereport(ERROR,
6651  errmsg_internal("cannot freeze committed xmax %u",
6652  xid)));
6653  freeze_xmax = true;
6654  /* No need for relfrozenxid_out handling, since we'll freeze xmax */
6655  }
6656  else
6657  {
6658  freeze_xmax = false;
6659  if (TransactionIdPrecedes(xid, *relfrozenxid_out))
6660  *relfrozenxid_out = xid;
6661  }
6662  }
6663  else if ((tuple->t_infomask & HEAP_XMAX_INVALID) ||
6665  {
6666  freeze_xmax = false;
6667  xmax_already_frozen = true;
6668  /* No need for relfrozenxid_out handling for already-frozen xmax */
6669  }
6670  else
6671  ereport(ERROR,
6673  errmsg_internal("found xmax %u (infomask 0x%04x) not frozen, not multi, not normal",
6674  xid, tuple->t_infomask)));
6675 
6676  if (freeze_xmax)
6677  {
6678  Assert(!xmax_already_frozen);
6679 
6680  frz->xmax = InvalidTransactionId;
6681 
6682  /*
6683  * The tuple might be marked either XMAX_INVALID or XMAX_COMMITTED +
6684  * LOCKED. Normalize to INVALID just to be sure no one gets confused.
6685  * Also get rid of the HEAP_KEYS_UPDATED bit.
6686  */
6687  frz->t_infomask &= ~HEAP_XMAX_BITS;
6688  frz->t_infomask |= HEAP_XMAX_INVALID;
6689  frz->t_infomask2 &= ~HEAP_HOT_UPDATED;
6690  frz->t_infomask2 &= ~HEAP_KEYS_UPDATED;
6691  changed = true;
6692  }
6693 
6694  /*
6695  * Old-style VACUUM FULL is gone, but we have to keep this code as long as
6696  * we support having MOVED_OFF/MOVED_IN tuples in the database.
6697  */
6698  if (tuple->t_infomask & HEAP_MOVED)
6699  {
6700  xid = HeapTupleHeaderGetXvac(tuple);
6701 
6702  /*
6703  * For Xvac, we ignore the cutoff_xid and just always perform the
6704  * freeze operation. The oldest release in which such a value can
6705  * actually be set is PostgreSQL 8.4, because old-style VACUUM FULL
6706  * was removed in PostgreSQL 9.0. Note that if we were to respect
6707  * cutoff_xid here, we'd need to make surely to clear totally_frozen
6708  * when we skipped freezing on that basis.
6709  *
6710  * No need for relfrozenxid_out handling, since we always freeze xvac.
6711  */
6712  if (TransactionIdIsNormal(xid))
6713  {
6714  /*
6715  * If a MOVED_OFF tuple is not dead, the xvac transaction must
6716  * have failed; whereas a non-dead MOVED_IN tuple must mean the
6717  * xvac transaction succeeded.
6718  */
6719  if (tuple->t_infomask & HEAP_MOVED_OFF)
6720  frz->frzflags |= XLH_INVALID_XVAC;
6721  else
6722  frz->frzflags |= XLH_FREEZE_XVAC;
6723 
6724  /*
6725  * Might as well fix the hint bits too; usually XMIN_COMMITTED
6726  * will already be set here, but there's a small chance not.
6727  */
6728  Assert(!(tuple->t_infomask & HEAP_XMIN_INVALID));
6730  changed = true;
6731  }
6732  }
6733 
6734  *totally_frozen = (xmin_frozen &&
6735  (freeze_xmax || xmax_already_frozen));
6736  return changed;
6737 }
unsigned short uint16
Definition: c.h:440
uint32 TransactionId
Definition: c.h:587
int errmsg_internal(const char *fmt,...)
Definition: elog.c:991
int errcode(int sqlerrcode)
Definition: elog.c:693
#define ERROR
Definition: elog.h:33
#define ereport(elevel,...)
Definition: elog.h:143
static void GetMultiXactIdHintBits(MultiXactId multi, uint16 *new_infomask, uint16 *new_infomask2)
Definition: heapam.c:6815
#define FRM_RETURN_IS_XID
Definition: heapam.c:6083
static TransactionId FreezeMultiXactId(MultiXactId multi, uint16 t_infomask, TransactionId relfrozenxid, TransactionId relminmxid, TransactionId cutoff_xid, MultiXactId cutoff_multi, uint16 *flags, TransactionId *mxid_oldest_xid_out)
Definition: heapam.c:6116
#define FRM_MARK_COMMITTED
Definition: heapam.c:6085
#define FRM_NOOP
Definition: heapam.c:6081
#define FRM_RETURN_IS_MULTI
Definition: heapam.c:6084
#define FRM_INVALIDATE_XMAX
Definition: heapam.c:6082
#define HEAP_MOVED_OFF
Definition: htup_details.h:210
#define HEAP_XMIN_FROZEN
Definition: htup_details.h:205
#define HEAP_XMAX_IS_LOCKED_ONLY(infomask)
Definition: htup_details.h:226
#define HEAP_XMIN_COMMITTED
Definition: htup_details.h:203
#define HEAP_KEYS_UPDATED
Definition: htup_details.h:274
#define HEAP_HOT_UPDATED
Definition: htup_details.h:275
#define HeapTupleHeaderGetXvac(tup)
Definition: htup_details.h:410
#define HeapTupleHeaderGetXmin(tup)
Definition: htup_details.h:308
#define HEAP_XMAX_BITS
Definition: htup_details.h:266
#define HEAP_MOVED
Definition: htup_details.h:212
#define HEAP_XMAX_IS_MULTI
Definition: htup_details.h:208
#define HEAP_XMIN_INVALID
Definition: htup_details.h:204
#define HeapTupleHeaderGetRawXmax(tup)
Definition: htup_details.h:370
Assert(fmt[strlen(fmt) - 1] !='\n')
bool MultiXactIdPrecedes(MultiXactId multi1, MultiXactId multi2)
Definition: multixact.c:3159
#define MultiXactIdIsValid(multi)
Definition: multixact.h:28
#define ERRCODE_DATA_CORRUPTED
Definition: pg_basebackup.c:43
TransactionId xmax
Definition: heapam_xlog.h:326
bool TransactionIdDidCommit(TransactionId transactionId)
Definition: transam.c:125
bool TransactionIdPrecedes(TransactionId id1, TransactionId id2)
Definition: transam.c:300
bool TransactionIdPrecedesOrEquals(TransactionId id1, TransactionId id2)
Definition: transam.c:319
#define TransactionIdIsValid(xid)
Definition: transam.h:41
#define TransactionIdIsNormal(xid)
Definition: transam.h:42

References Assert(), ereport, errcode(), ERRCODE_DATA_CORRUPTED, errmsg_internal(), ERROR, FreezeMultiXactId(), FRM_INVALIDATE_XMAX, FRM_MARK_COMMITTED, FRM_NOOP, FRM_RETURN_IS_MULTI, FRM_RETURN_IS_XID, xl_heap_freeze_tuple::frzflags, GetMultiXactIdHintBits(), HEAP_HOT_UPDATED, HEAP_KEYS_UPDATED, HEAP_MOVED, HEAP_MOVED_OFF, HEAP_XMAX_BITS, HEAP_XMAX_COMMITTED, HEAP_XMAX_INVALID, HEAP_XMAX_IS_LOCKED_ONLY, HEAP_XMAX_IS_MULTI, HEAP_XMIN_COMMITTED, HEAP_XMIN_FROZEN, HEAP_XMIN_INVALID, HeapTupleHeaderGetRawXmax, HeapTupleHeaderGetXmin, HeapTupleHeaderGetXvac, InvalidTransactionId, MultiXactIdIsValid, MultiXactIdPrecedes(), xl_heap_freeze_tuple::t_infomask, HeapTupleHeaderData::t_infomask, xl_heap_freeze_tuple::t_infomask2, HeapTupleHeaderData::t_infomask2, TransactionIdDidCommit(), TransactionIdIsNormal, TransactionIdIsValid, TransactionIdPrecedes(), TransactionIdPrecedesOrEquals(), XLH_FREEZE_XVAC, XLH_INVALID_XVAC, and xl_heap_freeze_tuple::xmax.

Referenced by heap_freeze_tuple(), and lazy_scan_prune().

◆ heap_redo()

void heap_redo ( XLogReaderState record)

Definition at line 9821 of file heapam.c.

9822 {
9823  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
9824 
9825  /*
9826  * These operations don't overwrite MVCC data so no conflict processing is
9827  * required. The ones in heap2 rmgr do.
9828  */
9829 
9830  switch (info & XLOG_HEAP_OPMASK)
9831  {
9832  case XLOG_HEAP_INSERT:
9833  heap_xlog_insert(record);
9834  break;
9835  case XLOG_HEAP_DELETE:
9836  heap_xlog_delete(record);
9837  break;
9838  case XLOG_HEAP_UPDATE:
9839  heap_xlog_update(record, false);
9840  break;
9841  case XLOG_HEAP_TRUNCATE:
9842 
9843  /*
9844  * TRUNCATE is a no-op because the actions are already logged as
9845  * SMGR WAL records. TRUNCATE WAL record only exists for logical
9846  * decoding.
9847  */
9848  break;
9849  case XLOG_HEAP_HOT_UPDATE:
9850  heap_xlog_update(record, true);
9851  break;
9852  case XLOG_HEAP_CONFIRM:
9853  heap_xlog_confirm(record);
9854  break;
9855  case XLOG_HEAP_LOCK:
9856  heap_xlog_lock(record);
9857  break;
9858  case XLOG_HEAP_INPLACE:
9859  heap_xlog_inplace(record);
9860  break;
9861  default:
9862  elog(PANIC, "heap_redo: unknown op code %u", info);
9863  }
9864 }
static void heap_xlog_insert(XLogReaderState *record)
Definition: heapam.c:9074
static void heap_xlog_update(XLogReaderState *record, bool hot_update)
Definition: heapam.c:9341
static void heap_xlog_delete(XLogReaderState *record)
Definition: heapam.c:9001
static void heap_xlog_lock(XLogReaderState *record)
Definition: heapam.c:9649
static void heap_xlog_inplace(XLogReaderState *record)
Definition: heapam.c:9780
static void heap_xlog_confirm(XLogReaderState *record)
Definition: heapam.c:9613

References elog, heap_xlog_confirm(), heap_xlog_delete(), heap_xlog_inplace(), heap_xlog_insert(), heap_xlog_lock(), heap_xlog_update(), PANIC, XLOG_HEAP_CONFIRM, XLOG_HEAP_DELETE, XLOG_HEAP_HOT_UPDATE, XLOG_HEAP_INPLACE, XLOG_HEAP_INSERT, XLOG_HEAP_LOCK, XLOG_HEAP_OPMASK, XLOG_HEAP_TRUNCATE, XLOG_HEAP_UPDATE, XLogRecGetInfo, and XLR_INFO_MASK.

◆ heap_xlog_logical_rewrite()

void heap_xlog_logical_rewrite ( XLogReaderState r)

Definition at line 1110 of file rewriteheap.c.

1111 {
1112  char path[MAXPGPATH];
1113  int fd;
1114  xl_heap_rewrite_mapping *xlrec;
1115  uint32 len;
1116  char *data;
1117 
1118  xlrec = (xl_heap_rewrite_mapping *) XLogRecGetData(r);
1119 
1120  snprintf(path, MAXPGPATH,
1121  "pg_logical/mappings/" LOGICAL_REWRITE_FORMAT,
1122  xlrec->mapped_db, xlrec->mapped_rel,
1123  LSN_FORMAT_ARGS(xlrec->start_lsn),
1124  xlrec->mapped_xid, XLogRecGetXid(r));
1125 
1126  fd = OpenTransientFile(path,
1127  O_CREAT | O_WRONLY | PG_BINARY);
1128  if (fd < 0)
1129  ereport(ERROR,
1131  errmsg("could not create file \"%s\": %m", path)));
1132 
1133  /*
1134  * Truncate all data that's not guaranteed to have been safely fsynced (by
1135  * previous record or by the last checkpoint).
1136  */
1138  if (ftruncate(fd, xlrec->offset) != 0)
1139  ereport(ERROR,
1141  errmsg("could not truncate file \"%s\" to %u: %m",
1142  path, (uint32) xlrec->offset)));
1144 
1145  data = XLogRecGetData(r) + sizeof(*xlrec);
1146 
1147  len = xlrec->num_mappings * sizeof(LogicalRewriteMappingData);
1148 
1149  /* write out tail end of mapping file (again) */
1150  errno = 0;
1152  if (pg_pwrite(fd, data, len, xlrec->offset) != len)
1153  {
1154  /* if write didn't set errno, assume problem is no disk space */
1155  if (errno == 0)
1156  errno = ENOSPC;
1157  ereport(ERROR,
1159  errmsg("could not write to file \"%s\": %m", path)));
1160  }
1162 
1163  /*
1164  * Now fsync all previously written data. We could improve things and only
1165  * do this for the last write to a file, but the required bookkeeping
1166  * doesn't seem worth the trouble.
1167  */
1169  if (pg_fsync(fd) != 0)
1172  errmsg("could not fsync file \"%s\": %m", path)));
1174 
1175  if (CloseTransientFile(fd) != 0)
1176  ereport(ERROR,
1178  errmsg("could not close file \"%s\": %m", path)));
1179 }
unsigned int uint32
Definition: c.h:441
#define PG_BINARY
Definition: c.h:1268
int errcode_for_file_access(void)
Definition: elog.c:716
int errmsg(const char *fmt,...)
Definition: elog.c:904
int CloseTransientFile(int fd)
Definition: fd.c:2688
int data_sync_elevel(int elevel)
Definition: fd.c:3826
int pg_fsync(int fd)
Definition: fd.c:359
int OpenTransientFile(const char *fileName, int fileFlags)
Definition: fd.c:2511
#define MAXPGPATH
const void * data
ssize_t pg_pwrite(int fd, const void *buf, size_t nbyte, off_t offset)
Definition: pwrite.c:27
#define snprintf
Definition: port.h:225
static int fd(const char *x, int i)
Definition: preproc-init.c:105
#define LOGICAL_REWRITE_FORMAT
Definition: rewriteheap.h:54
struct LogicalRewriteMappingData LogicalRewriteMappingData
TransactionId mapped_xid
Definition: heapam_xlog.h:384
@ WAIT_EVENT_LOGICAL_REWRITE_MAPPING_SYNC
Definition: wait_event.h:190
@ WAIT_EVENT_LOGICAL_REWRITE_MAPPING_WRITE
Definition: wait_event.h:191
@ WAIT_EVENT_LOGICAL_REWRITE_TRUNCATE
Definition: wait_event.h:193
static void pgstat_report_wait_start(uint32 wait_event_info)
Definition: wait_event.h:266
static void pgstat_report_wait_end(void)
Definition: wait_event.h:282
#define ftruncate(a, b)
Definition: win32_port.h:73
#define LSN_FORMAT_ARGS(lsn)
Definition: xlogdefs.h:43
#define XLogRecGetXid(decoder)
Definition: xlogreader.h:410

References CloseTransientFile(), data, data_sync_elevel(), ereport, errcode_for_file_access(), errmsg(), ERROR, fd(), ftruncate, len, LOGICAL_REWRITE_FORMAT, LSN_FORMAT_ARGS, xl_heap_rewrite_mapping::mapped_db, xl_heap_rewrite_mapping::mapped_rel, xl_heap_rewrite_mapping::mapped_xid, MAXPGPATH, xl_heap_rewrite_mapping::num_mappings, xl_heap_rewrite_mapping::offset, OpenTransientFile(), PG_BINARY, pg_fsync(), pg_pwrite(), pgstat_report_wait_end(), pgstat_report_wait_start(), snprintf, xl_heap_rewrite_mapping::start_lsn, WAIT_EVENT_LOGICAL_REWRITE_MAPPING_SYNC, WAIT_EVENT_LOGICAL_REWRITE_MAPPING_WRITE, WAIT_EVENT_LOGICAL_REWRITE_TRUNCATE, XLogRecGetData, and XLogRecGetXid.

Referenced by heap2_redo().

◆ HeapTupleHeaderAdvanceLatestRemovedXid()

void HeapTupleHeaderAdvanceLatestRemovedXid ( HeapTupleHeader  tuple,
TransactionId latestRemovedXid 
)

Definition at line 7328 of file heapam.c.

7330 {
7331  TransactionId xmin = HeapTupleHeaderGetXmin(tuple);
7333  TransactionId xvac = HeapTupleHeaderGetXvac(tuple);
7334 
7335  if (tuple->t_infomask & HEAP_MOVED)
7336  {
7337  if (TransactionIdPrecedes(*latestRemovedXid, xvac))
7338  *latestRemovedXid = xvac;
7339  }
7340 
7341  /*
7342  * Ignore tuples inserted by an aborted transaction or if the tuple was
7343  * updated/deleted by the inserting transaction.
7344  *
7345  * Look for a committed hint bit, or if no xmin bit is set, check clog.
7346  */
7347  if (HeapTupleHeaderXminCommitted(tuple) ||
7349  {
7350  if (xmax != xmin &&
7351  TransactionIdFollows(xmax, *latestRemovedXid))
7352  *latestRemovedXid = xmax;
7353  }
7354 
7355  /* *latestRemovedXid may still be invalid at end */
7356 }
#define HeapTupleHeaderXminCommitted(tup)
Definition: htup_details.h:319
#define HeapTupleHeaderGetUpdateXid(tup)
Definition: htup_details.h:360
#define HeapTupleHeaderXminInvalid(tup)
Definition: htup_details.h:324
bool TransactionIdFollows(TransactionId id1, TransactionId id2)
Definition: transam.c:334

References HEAP_MOVED, HeapTupleHeaderGetUpdateXid, HeapTupleHeaderGetXmin, HeapTupleHeaderGetXvac, HeapTupleHeaderXminCommitted, HeapTupleHeaderXminInvalid, HeapTupleHeaderData::t_infomask, TransactionIdDidCommit(), TransactionIdFollows(), and TransactionIdPrecedes().

Referenced by heap_index_delete_tuples(), and heap_prune_chain().

◆ log_heap_freeze()

XLogRecPtr log_heap_freeze ( Relation  reln,
Buffer  buffer,
TransactionId  cutoff_xid,
xl_heap_freeze_tuple tuples,
int  ntuples 
)

Definition at line 8151 of file heapam.c.

8153 {
8154  xl_heap_freeze_page xlrec;
8155  XLogRecPtr recptr;
8156 
8157  /* Caller should not call me on a non-WAL-logged relation */
8158  Assert(RelationNeedsWAL(reln));
8159  /* nor when there are no tuples to freeze */
8160  Assert(ntuples > 0);
8161 
8162  xlrec.cutoff_xid = cutoff_xid;
8163  xlrec.ntuples = ntuples;
8164 
8165  XLogBeginInsert();
8166  XLogRegisterData((char *) &xlrec, SizeOfHeapFreezePage);
8167 
8168  /*
8169  * The freeze plan array is not actually in the buffer, but pretend that
8170  * it is. When XLogInsert stores the whole buffer, the freeze plan need
8171  * not be stored too.
8172  */
8173  XLogRegisterBuffer(0, buffer, REGBUF_STANDARD);
8174  XLogRegisterBufData(0, (char *) tuples,
8175  ntuples * sizeof(xl_heap_freeze_tuple));
8176 
8177  recptr = XLogInsert(RM_HEAP2_ID, XLOG_HEAP2_FREEZE_PAGE);
8178 
8179  return recptr;
8180 }
#define SizeOfHeapFreezePage
Definition: heapam_xlog.h:345
#define RelationNeedsWAL(relation)
Definition: rel.h:613
uint64 XLogRecPtr
Definition: xlogdefs.h:21
XLogRecPtr XLogInsert(RmgrId rmid, uint8 info)
Definition: xloginsert.c:443
void XLogRegisterBufData(uint8 block_id, char *data, int len)
Definition: xloginsert.c:389
void XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags)
Definition: xloginsert.c:243
void XLogBeginInsert(void)
Definition: xloginsert.c:150
void XLogRegisterData(char *data, int len)
Definition: xloginsert.c:351
#define REGBUF_STANDARD
Definition: xloginsert.h:34

References Assert(), xl_heap_freeze_page::cutoff_xid, xl_heap_freeze_page::ntuples, REGBUF_STANDARD, RelationNeedsWAL, SizeOfHeapFreezePage, XLOG_HEAP2_FREEZE_PAGE, XLogBeginInsert(), XLogInsert(), XLogRegisterBufData(), XLogRegisterBuffer(), and XLogRegisterData().

Referenced by lazy_scan_prune().

◆ log_heap_visible()

XLogRecPtr log_heap_visible ( RelFileNode  rnode,
Buffer  heap_buffer,
Buffer  vm_buffer,
TransactionId  cutoff_xid,
uint8  flags 
)

Definition at line 8192 of file heapam.c.

8194 {
8195  xl_heap_visible xlrec;
8196  XLogRecPtr recptr;
8197  uint8 flags;
8198 
8199  Assert(BufferIsValid(heap_buffer));
8200  Assert(BufferIsValid(vm_buffer));
8201 
8202  xlrec.cutoff_xid = cutoff_xid;
8203  xlrec.flags = vmflags;
8204  XLogBeginInsert();
8205  XLogRegisterData((char *) &xlrec, SizeOfHeapVisible);
8206 
8207  XLogRegisterBuffer(0, vm_buffer, 0);
8208 
8209  flags = REGBUF_STANDARD;
8210  if (!XLogHintBitIsNeeded())
8211  flags |= REGBUF_NO_IMAGE;
8212  XLogRegisterBuffer(1, heap_buffer, flags);
8213 
8214  recptr = XLogInsert(RM_HEAP2_ID, XLOG_HEAP2_VISIBLE);
8215 
8216  return recptr;
8217 }
#define BufferIsValid(bufnum)
Definition: bufmgr.h:123
#define SizeOfHeapVisible
Definition: heapam_xlog.h:359
#define XLogHintBitIsNeeded()
Definition: xlog.h:115
#define REGBUF_NO_IMAGE
Definition: xloginsert.h:32

References Assert(), BufferIsValid, xl_heap_visible::cutoff_xid, xl_heap_visible::flags, REGBUF_NO_IMAGE, REGBUF_STANDARD, SizeOfHeapVisible, XLOG_HEAP2_VISIBLE, XLogBeginInsert(), XLogHintBitIsNeeded, XLogInsert(), XLogRegisterBuffer(), and XLogRegisterData().

Referenced by visibilitymap_set().