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_clean
 
struct  xl_heap_cleanup_info
 
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_CLEAN   0x10
 
#define XLOG_HEAP2_FREEZE_PAGE   0x20
 
#define XLOG_HEAP2_CLEANUP_INFO   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_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 SizeOfHeapClean   (offsetof(xl_heap_clean, ndead) + sizeof(uint16))
 
#define SizeOfHeapCleanupInfo   (sizeof(xl_heap_cleanup_info))
 
#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_clean xl_heap_clean
 
typedef struct xl_heap_cleanup_info xl_heap_cleanup_info
 
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_cleanup_info (RelFileNode rnode, TransactionId latestRemovedXid)
 
XLogRecPtr log_heap_clean (Relation reln, Buffer buffer, OffsetNumber *redirected, int nredirected, OffsetNumber *nowdead, int ndead, OffsetNumber *nowunused, int nunused, TransactionId latestRemovedXid)
 
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)
 
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

◆ SizeOfHeapClean

#define SizeOfHeapClean   (offsetof(xl_heap_clean, ndead) + sizeof(uint16))

Definition at line 246 of file heapam_xlog.h.

Referenced by log_heap_clean().

◆ SizeOfHeapCleanupInfo

#define SizeOfHeapCleanupInfo   (sizeof(xl_heap_cleanup_info))

Definition at line 259 of file heapam_xlog.h.

Referenced by log_heap_cleanup_info().

◆ SizeOfHeapConfirm

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

Definition at line 299 of file heapam_xlog.h.

Referenced by heap_finish_speculative().

◆ SizeOfHeapDelete

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

Definition at line 111 of file heapam_xlog.h.

Referenced by DecodeDelete(), heap_abort_speculative(), and heap_delete().

◆ SizeOfHeapFreezePage

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

Definition at line 339 of file heapam_xlog.h.

Referenced by log_heap_freeze().

◆ SizeOfHeapHeader

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

◆ SizeOfHeapInplace

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

Definition at line 308 of file heapam_xlog.h.

Referenced by heap_inplace_update().

◆ SizeOfHeapInsert

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

Definition at line 160 of file heapam_xlog.h.

Referenced by heap_insert().

◆ SizeOfHeapLock

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

Definition at line 280 of file heapam_xlog.h.

Referenced by heap_lock_tuple(), and heap_update().

◆ SizeOfHeapLockUpdated

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

Definition at line 291 of file heapam_xlog.h.

Referenced by heap_lock_updated_tuple_rec().

◆ SizeOfHeapMultiInsert

#define SizeOfHeapMultiInsert   offsetof(xl_heap_multi_insert, offsets)

Definition at line 180 of file heapam_xlog.h.

Referenced by heap_multi_insert().

◆ SizeOfHeapNewCid

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

Definition at line 373 of file heapam_xlog.h.

Referenced by log_heap_new_cid().

◆ SizeOfHeapTruncate

#define SizeOfHeapTruncate   (offsetof(xl_heap_truncate, relids))

Definition at line 132 of file heapam_xlog.h.

Referenced by ExecuteTruncateGuts().

◆ SizeOfHeapUpdate

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

Definition at line 225 of file heapam_xlog.h.

Referenced by DecodeUpdate(), and log_heap_update().

◆ SizeOfHeapVisible

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

Definition at line 353 of file heapam_xlog.h.

Referenced by log_heap_visible().

◆ SizeOfMultiInsertTuple

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

Definition at line 191 of file heapam_xlog.h.

Referenced by DecodeMultiInsert(), heap_multi_insert(), and heap_xlog_multi_insert().

◆ XLH_DELETE_ALL_VISIBLE_CLEARED

#define XLH_DELETE_ALL_VISIBLE_CLEARED   (1<<0)

Definition at line 92 of file heapam_xlog.h.

Referenced by heap_delete(), and heap_xlog_delete().

◆ XLH_DELETE_CONTAINS_OLD

#define XLH_DELETE_CONTAINS_OLD   (XLH_DELETE_CONTAINS_OLD_TUPLE | XLH_DELETE_CONTAINS_OLD_KEY)

Definition at line 99 of file heapam_xlog.h.

Referenced by DecodeDelete().

◆ XLH_DELETE_CONTAINS_OLD_KEY

#define XLH_DELETE_CONTAINS_OLD_KEY   (1<<2)

Definition at line 94 of file heapam_xlog.h.

Referenced by heap_delete().

◆ XLH_DELETE_CONTAINS_OLD_TUPLE

#define XLH_DELETE_CONTAINS_OLD_TUPLE   (1<<1)

Definition at line 93 of file heapam_xlog.h.

Referenced by heap_delete().

◆ XLH_DELETE_IS_PARTITION_MOVE

#define XLH_DELETE_IS_PARTITION_MOVE   (1<<4)

Definition at line 96 of file heapam_xlog.h.

Referenced by heap_delete(), and heap_xlog_delete().

◆ XLH_DELETE_IS_SUPER

#define XLH_DELETE_IS_SUPER   (1<<3)

Definition at line 95 of file heapam_xlog.h.

Referenced by DecodeDelete(), heap_abort_speculative(), and heap_xlog_delete().

◆ XLH_FREEZE_XVAC

#define XLH_FREEZE_XVAC   0x02

Definition at line 315 of file heapam_xlog.h.

Referenced by heap_execute_freeze_tuple(), and heap_prepare_freeze_tuple().

◆ XLH_INSERT_ALL_VISIBLE_CLEARED

#define XLH_INSERT_ALL_VISIBLE_CLEARED   (1<<0)

◆ XLH_INSERT_CONTAINS_NEW_TUPLE

#define XLH_INSERT_CONTAINS_NEW_TUPLE   (1<<3)

Definition at line 69 of file heapam_xlog.h.

Referenced by DecodeInsert(), DecodeMultiInsert(), heap_insert(), and heap_multi_insert().

◆ XLH_INSERT_IS_SPECULATIVE

#define XLH_INSERT_IS_SPECULATIVE   (1<<2)

Definition at line 68 of file heapam_xlog.h.

Referenced by DecodeInsert(), and heap_insert().

◆ XLH_INSERT_LAST_IN_MULTI

#define XLH_INSERT_LAST_IN_MULTI   (1<<1)

Definition at line 67 of file heapam_xlog.h.

Referenced by DecodeMultiInsert(), and heap_multi_insert().

◆ XLH_INVALID_XVAC

#define XLH_INVALID_XVAC   0x04

Definition at line 316 of file heapam_xlog.h.

Referenced by heap_execute_freeze_tuple(), and heap_prepare_freeze_tuple().

◆ XLH_LOCK_ALL_FROZEN_CLEARED

#define XLH_LOCK_ALL_FROZEN_CLEARED   0x01

◆ XLH_TRUNCATE_CASCADE

#define XLH_TRUNCATE_CASCADE   (1<<0)

Definition at line 116 of file heapam_xlog.h.

Referenced by DecodeTruncate(), ExecuteTruncateGuts(), and heap_desc().

◆ XLH_TRUNCATE_RESTART_SEQS

#define XLH_TRUNCATE_RESTART_SEQS   (1<<1)

Definition at line 117 of file heapam_xlog.h.

Referenced by DecodeTruncate(), ExecuteTruncateGuts(), and heap_desc().

◆ XLH_UPDATE_CONTAINS_NEW_TUPLE

#define XLH_UPDATE_CONTAINS_NEW_TUPLE   (1<<4)

Definition at line 80 of file heapam_xlog.h.

Referenced by DecodeUpdate(), and log_heap_update().

◆ XLH_UPDATE_CONTAINS_OLD

#define XLH_UPDATE_CONTAINS_OLD   (XLH_UPDATE_CONTAINS_OLD_TUPLE | XLH_UPDATE_CONTAINS_OLD_KEY)

Definition at line 85 of file heapam_xlog.h.

Referenced by DecodeUpdate().

◆ XLH_UPDATE_CONTAINS_OLD_KEY

#define XLH_UPDATE_CONTAINS_OLD_KEY   (1<<3)

Definition at line 79 of file heapam_xlog.h.

Referenced by log_heap_update().

◆ XLH_UPDATE_CONTAINS_OLD_TUPLE

#define XLH_UPDATE_CONTAINS_OLD_TUPLE   (1<<2)

Definition at line 78 of file heapam_xlog.h.

Referenced by log_heap_update().

◆ XLH_UPDATE_NEW_ALL_VISIBLE_CLEARED

#define XLH_UPDATE_NEW_ALL_VISIBLE_CLEARED   (1<<1)

Definition at line 77 of file heapam_xlog.h.

Referenced by heap_xlog_update(), and log_heap_update().

◆ XLH_UPDATE_OLD_ALL_VISIBLE_CLEARED

#define XLH_UPDATE_OLD_ALL_VISIBLE_CLEARED   (1<<0)

Definition at line 75 of file heapam_xlog.h.

Referenced by heap_xlog_update(), and log_heap_update().

◆ XLH_UPDATE_PREFIX_FROM_OLD

#define XLH_UPDATE_PREFIX_FROM_OLD   (1<<5)

Definition at line 81 of file heapam_xlog.h.

Referenced by heap_xlog_update(), and log_heap_update().

◆ XLH_UPDATE_SUFFIX_FROM_OLD

#define XLH_UPDATE_SUFFIX_FROM_OLD   (1<<6)

Definition at line 82 of file heapam_xlog.h.

Referenced by heap_xlog_update(), and log_heap_update().

◆ XLHL_KEYS_UPDATED

#define XLHL_KEYS_UPDATED   0x10

Definition at line 266 of file heapam_xlog.h.

Referenced by compute_infobits(), fix_infomask_from_infobits(), and out_infobits().

◆ XLHL_XMAX_EXCL_LOCK

#define XLHL_XMAX_EXCL_LOCK   0x04

Definition at line 264 of file heapam_xlog.h.

Referenced by compute_infobits(), fix_infomask_from_infobits(), and out_infobits().

◆ XLHL_XMAX_IS_MULTI

#define XLHL_XMAX_IS_MULTI   0x01

Definition at line 262 of file heapam_xlog.h.

Referenced by compute_infobits(), fix_infomask_from_infobits(), and out_infobits().

◆ XLHL_XMAX_KEYSHR_LOCK

#define XLHL_XMAX_KEYSHR_LOCK   0x08

Definition at line 265 of file heapam_xlog.h.

Referenced by compute_infobits(), fix_infomask_from_infobits(), and out_infobits().

◆ XLHL_XMAX_LOCK_ONLY

#define XLHL_XMAX_LOCK_ONLY   0x02

Definition at line 263 of file heapam_xlog.h.

Referenced by compute_infobits(), fix_infomask_from_infobits(), and out_infobits().

◆ XLOG_HEAP2_CLEAN

#define XLOG_HEAP2_CLEAN   0x10

Definition at line 54 of file heapam_xlog.h.

Referenced by DecodeHeap2Op(), heap2_desc(), heap2_identify(), heap2_redo(), and log_heap_clean().

◆ XLOG_HEAP2_CLEANUP_INFO

#define XLOG_HEAP2_CLEANUP_INFO   0x30

◆ XLOG_HEAP2_FREEZE_PAGE

#define XLOG_HEAP2_FREEZE_PAGE   0x20

Definition at line 55 of file heapam_xlog.h.

Referenced by DecodeHeap2Op(), heap2_desc(), heap2_identify(), heap2_redo(), and log_heap_freeze().

◆ XLOG_HEAP2_LOCK_UPDATED

#define XLOG_HEAP2_LOCK_UPDATED   0x60

◆ XLOG_HEAP2_MULTI_INSERT

#define XLOG_HEAP2_MULTI_INSERT   0x50

◆ XLOG_HEAP2_NEW_CID

#define XLOG_HEAP2_NEW_CID   0x70

Definition at line 60 of file heapam_xlog.h.

Referenced by DecodeHeap2Op(), heap2_desc(), heap2_identify(), heap2_redo(), and log_heap_new_cid().

◆ XLOG_HEAP2_REWRITE

#define XLOG_HEAP2_REWRITE   0x00

◆ XLOG_HEAP2_VISIBLE

#define XLOG_HEAP2_VISIBLE   0x40

Definition at line 57 of file heapam_xlog.h.

Referenced by DecodeHeap2Op(), heap2_desc(), heap2_identify(), heap2_redo(), and log_heap_visible().

◆ XLOG_HEAP_CONFIRM

#define XLOG_HEAP_CONFIRM   0x50

◆ XLOG_HEAP_DELETE

#define XLOG_HEAP_DELETE   0x10

◆ XLOG_HEAP_HOT_UPDATE

#define XLOG_HEAP_HOT_UPDATE   0x40

Definition at line 36 of file heapam_xlog.h.

Referenced by DecodeHeapOp(), heap_desc(), heap_identify(), heap_redo(), and log_heap_update().

◆ XLOG_HEAP_INIT_PAGE

◆ XLOG_HEAP_INPLACE

#define XLOG_HEAP_INPLACE   0x70

Definition at line 39 of file heapam_xlog.h.

Referenced by DecodeHeapOp(), heap_desc(), heap_identify(), heap_inplace_update(), and heap_redo().

◆ XLOG_HEAP_INSERT

#define XLOG_HEAP_INSERT   0x00

Definition at line 32 of file heapam_xlog.h.

Referenced by DecodeHeapOp(), heap_desc(), heap_identify(), heap_insert(), and heap_redo().

◆ XLOG_HEAP_LOCK

#define XLOG_HEAP_LOCK   0x60

◆ XLOG_HEAP_OPMASK

#define XLOG_HEAP_OPMASK   0x70

Definition at line 41 of file heapam_xlog.h.

Referenced by DecodeHeap2Op(), DecodeHeapOp(), heap2_desc(), heap2_redo(), heap_desc(), and heap_redo().

◆ XLOG_HEAP_TRUNCATE

#define XLOG_HEAP_TRUNCATE   0x30

Definition at line 35 of file heapam_xlog.h.

Referenced by DecodeHeapOp(), ExecuteTruncateGuts(), heap_desc(), heap_identify(), and heap_redo().

◆ XLOG_HEAP_UPDATE

#define XLOG_HEAP_UPDATE   0x20

Definition at line 34 of file heapam_xlog.h.

Referenced by DecodeHeapOp(), heap_desc(), heap_identify(), heap_redo(), and log_heap_update().

Typedef Documentation

◆ xl_heap_clean

typedef struct xl_heap_clean xl_heap_clean

◆ xl_heap_cleanup_info

◆ 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_rewrite_mapping

◆ xl_heap_truncate

◆ xl_heap_update

◆ 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.

References appendStringInfo(), 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_clean::latestRemovedXid, xl_heap_cleanup_info::latestRemovedXid, xl_heap_multi_insert::ntuples, xl_heap_freeze_page::ntuples, 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_CLEAN, XLOG_HEAP2_CLEANUP_INFO, XLOG_HEAP2_FREEZE_PAGE, XLOG_HEAP2_LOCK_UPDATED, XLOG_HEAP2_MULTI_INSERT, XLOG_HEAP2_NEW_CID, XLOG_HEAP2_VISIBLE, XLOG_HEAP_OPMASK, XLogRecGetData, XLogRecGetInfo, XLR_INFO_MASK, and xl_heap_lock_updated::xmax.

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_CLEAN)
125  {
126  xl_heap_clean *xlrec = (xl_heap_clean *) rec;
127 
128  appendStringInfo(buf, "remxid %u", xlrec->latestRemovedXid);
129  }
130  else if (info == XLOG_HEAP2_FREEZE_PAGE)
131  {
132  xl_heap_freeze_page *xlrec = (xl_heap_freeze_page *) rec;
133 
134  appendStringInfo(buf, "cutoff xid %u ntuples %u",
135  xlrec->cutoff_xid, xlrec->ntuples);
136  }
137  else if (info == XLOG_HEAP2_CLEANUP_INFO)
138  {
140 
141  appendStringInfo(buf, "remxid %u", xlrec->latestRemovedXid);
142  }
143  else if (info == XLOG_HEAP2_VISIBLE)
144  {
145  xl_heap_visible *xlrec = (xl_heap_visible *) rec;
146 
147  appendStringInfo(buf, "cutoff xid %u flags 0x%02X",
148  xlrec->cutoff_xid, xlrec->flags);
149  }
150  else if (info == XLOG_HEAP2_MULTI_INSERT)
151  {
153 
154  appendStringInfo(buf, "%d tuples flags 0x%02X", xlrec->ntuples,
155  xlrec->flags);
156  }
157  else if (info == XLOG_HEAP2_LOCK_UPDATED)
158  {
160 
161  appendStringInfo(buf, "off %u: xmax %u: flags 0x%02X ",
162  xlrec->offnum, xlrec->xmax, xlrec->flags);
163  out_infobits(buf, xlrec->infobits_set);
164  }
165  else if (info == XLOG_HEAP2_NEW_CID)
166  {
167  xl_heap_new_cid *xlrec = (xl_heap_new_cid *) rec;
168 
169  appendStringInfo(buf, "rel %u/%u/%u; tid %u/%u",
170  xlrec->target_node.spcNode,
171  xlrec->target_node.dbNode,
172  xlrec->target_node.relNode,
175  appendStringInfo(buf, "; cmin: %u, cmax: %u, combo: %u",
176  xlrec->cmin, xlrec->cmax, xlrec->combocid);
177  }
178 }
#define XLOG_HEAP2_LOCK_UPDATED
Definition: heapam_xlog.h:59
CommandId combocid
Definition: heapam_xlog.h:364
TransactionId cutoff_xid
Definition: heapam_xlog.h:335
unsigned char uint8
Definition: c.h:372
#define XLOG_HEAP_OPMASK
Definition: heapam_xlog.h:41
CommandId cmax
Definition: heapam_xlog.h:363
ItemPointerData target_tid
Definition: heapam_xlog.h:370
OffsetNumber offnum
Definition: heapam_xlog.h:286
#define XLOG_HEAP2_MULTI_INSERT
Definition: heapam_xlog.h:58
#define XLOG_HEAP2_VISIBLE
Definition: heapam_xlog.h:57
#define XLogRecGetData(decoder)
Definition: xlogreader.h:310
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:91
TransactionId cutoff_xid
Definition: heapam_xlog.h:349
#define XLOG_HEAP2_CLEAN
Definition: heapam_xlog.h:54
#define XLOG_HEAP2_CLEANUP_INFO
Definition: heapam_xlog.h:56
static void out_infobits(StringInfo buf, uint8 infobits)
Definition: heapdesc.c:20
#define XLOG_HEAP2_NEW_CID
Definition: heapam_xlog.h:60
TransactionId xmax
Definition: heapam_xlog.h:285
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:305
RelFileNode target_node
Definition: heapam_xlog.h:369
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
#define ItemPointerGetOffsetNumber(pointer)
Definition: itemptr.h:117
#define XLOG_HEAP2_FREEZE_PAGE
Definition: heapam_xlog.h:55
TransactionId latestRemovedXid
Definition: heapam_xlog.h:240
CommandId cmin
Definition: heapam_xlog.h:362
#define ItemPointerGetBlockNumber(pointer)
Definition: itemptr.h:98
TransactionId latestRemovedXid
Definition: heapam_xlog.h:256

◆ heap2_identify()

const char* heap2_identify ( uint8  info)

Definition at line 226 of file heapdesc.c.

References XLOG_HEAP2_CLEAN, XLOG_HEAP2_CLEANUP_INFO, XLOG_HEAP2_FREEZE_PAGE, XLOG_HEAP2_LOCK_UPDATED, XLOG_HEAP2_MULTI_INSERT, XLOG_HEAP2_NEW_CID, XLOG_HEAP2_REWRITE, XLOG_HEAP2_VISIBLE, XLOG_HEAP_INIT_PAGE, and XLR_INFO_MASK.

227 {
228  const char *id = NULL;
229 
230  switch (info & ~XLR_INFO_MASK)
231  {
232  case XLOG_HEAP2_CLEAN:
233  id = "CLEAN";
234  break;
236  id = "FREEZE_PAGE";
237  break;
239  id = "CLEANUP_INFO";
240  break;
241  case XLOG_HEAP2_VISIBLE:
242  id = "VISIBLE";
243  break;
245  id = "MULTI_INSERT";
246  break;
248  id = "MULTI_INSERT+INIT";
249  break;
251  id = "LOCK_UPDATED";
252  break;
253  case XLOG_HEAP2_NEW_CID:
254  id = "NEW_CID";
255  break;
256  case XLOG_HEAP2_REWRITE:
257  id = "REWRITE";
258  break;
259  }
260 
261  return id;
262 }
#define XLOG_HEAP2_LOCK_UPDATED
Definition: heapam_xlog.h:59
#define XLOG_HEAP2_REWRITE
Definition: heapam_xlog.h:53
#define XLOG_HEAP_INIT_PAGE
Definition: heapam_xlog.h:46
#define XLOG_HEAP2_MULTI_INSERT
Definition: heapam_xlog.h:58
#define XLOG_HEAP2_VISIBLE
Definition: heapam_xlog.h:57
#define XLOG_HEAP2_CLEAN
Definition: heapam_xlog.h:54
#define XLOG_HEAP2_CLEANUP_INFO
Definition: heapam_xlog.h:56
#define XLOG_HEAP2_NEW_CID
Definition: heapam_xlog.h:60
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
#define XLOG_HEAP2_FREEZE_PAGE
Definition: heapam_xlog.h:55

◆ heap2_redo()

void heap2_redo ( XLogReaderState record)

Definition at line 8864 of file heapam.c.

References elog, heap_xlog_clean(), heap_xlog_cleanup_info(), heap_xlog_freeze_page(), heap_xlog_lock_updated(), heap_xlog_logical_rewrite(), heap_xlog_multi_insert(), heap_xlog_visible(), PANIC, XLOG_HEAP2_CLEAN, XLOG_HEAP2_CLEANUP_INFO, XLOG_HEAP2_FREEZE_PAGE, XLOG_HEAP2_LOCK_UPDATED, XLOG_HEAP2_MULTI_INSERT, XLOG_HEAP2_NEW_CID, XLOG_HEAP2_REWRITE, XLOG_HEAP2_VISIBLE, XLOG_HEAP_OPMASK, XLogRecGetInfo, and XLR_INFO_MASK.

8865 {
8866  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
8867 
8868  switch (info & XLOG_HEAP_OPMASK)
8869  {
8870  case XLOG_HEAP2_CLEAN:
8871  heap_xlog_clean(record);
8872  break;
8874  heap_xlog_freeze_page(record);
8875  break;
8877  heap_xlog_cleanup_info(record);
8878  break;
8879  case XLOG_HEAP2_VISIBLE:
8880  heap_xlog_visible(record);
8881  break;
8883  heap_xlog_multi_insert(record);
8884  break;
8886  heap_xlog_lock_updated(record);
8887  break;
8888  case XLOG_HEAP2_NEW_CID:
8889 
8890  /*
8891  * Nothing to do on a real replay, only used during logical
8892  * decoding.
8893  */
8894  break;
8895  case XLOG_HEAP2_REWRITE:
8896  heap_xlog_logical_rewrite(record);
8897  break;
8898  default:
8899  elog(PANIC, "heap2_redo: unknown op code %u", info);
8900  }
8901 }
void heap_xlog_logical_rewrite(XLogReaderState *r)
Definition: rewriteheap.c:1112
#define XLOG_HEAP2_LOCK_UPDATED
Definition: heapam_xlog.h:59
#define XLOG_HEAP2_REWRITE
Definition: heapam_xlog.h:53
unsigned char uint8
Definition: c.h:372
#define XLOG_HEAP_OPMASK
Definition: heapam_xlog.h:41
#define PANIC
Definition: elog.h:53
#define XLOG_HEAP2_MULTI_INSERT
Definition: heapam_xlog.h:58
#define XLOG_HEAP2_VISIBLE
Definition: heapam_xlog.h:57
static void heap_xlog_lock_updated(XLogReaderState *record)
Definition: heapam.c:8717
static void heap_xlog_freeze_page(XLogReaderState *record)
Definition: heapam.c:7931
#define XLOG_HEAP2_CLEAN
Definition: heapam_xlog.h:54
#define XLOG_HEAP2_CLEANUP_INFO
Definition: heapam_xlog.h:56
static void heap_xlog_multi_insert(XLogReaderState *record)
Definition: heapam.c:8199
#define XLOG_HEAP2_NEW_CID
Definition: heapam_xlog.h:60
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:305
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
static void heap_xlog_cleanup_info(XLogReaderState *record)
Definition: heapam.c:7677
#define XLOG_HEAP2_FREEZE_PAGE
Definition: heapam_xlog.h:55
#define elog(elevel,...)
Definition: elog.h:214
static void heap_xlog_visible(XLogReaderState *record)
Definition: heapam.c:7791
static void heap_xlog_clean(XLogReaderState *record)
Definition: heapam.c:7698

◆ heap_desc()

void heap_desc ( StringInfo  buf,
XLogReaderState record 
)

Definition at line 35 of file heapdesc.c.

References appendStringInfo(), appendStringInfoString(), 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.

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);
65  out_infobits(buf, xlrec->old_infobits_set);
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);
78  out_infobits(buf, xlrec->old_infobits_set);
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 XLH_TRUNCATE_CASCADE
Definition: heapam_xlog.h:116
#define XLOG_HEAP_INSERT
Definition: heapam_xlog.h:32
uint8 old_infobits_set
Definition: heapam_xlog.h:214
OffsetNumber offnum
Definition: heapam_xlog.h:296
OffsetNumber offnum
Definition: heapam_xlog.h:275
TransactionId locking_xid
Definition: heapam_xlog.h:274
unsigned char uint8
Definition: c.h:372
#define XLOG_HEAP_OPMASK
Definition: heapam_xlog.h:41
#define XLOG_HEAP_HOT_UPDATE
Definition: heapam_xlog.h:36
OffsetNumber old_offnum
Definition: heapam_xlog.h:213
OffsetNumber offnum
Definition: heapam_xlog.h:106
Oid relids[FLEXIBLE_ARRAY_MEMBER]
Definition: heapam_xlog.h:129
#define XLogRecGetData(decoder)
Definition: xlogreader.h:310
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:91
TransactionId new_xmax
Definition: heapam_xlog.h:216
int8 infobits_set
Definition: heapam_xlog.h:276
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:176
static void out_infobits(StringInfo buf, uint8 infobits)
Definition: heapdesc.c:20
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:305
OffsetNumber offnum
Definition: heapam_xlog.h:304
#define XLH_TRUNCATE_RESTART_SEQS
Definition: heapam_xlog.h:117
#define XLOG_HEAP_TRUNCATE
Definition: heapam_xlog.h:35
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
uint8 infobits_set
Definition: heapam_xlog.h:107
#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
int i
OffsetNumber new_offnum
Definition: heapam_xlog.h:217
#define XLOG_HEAP_DELETE
Definition: heapam_xlog.h:33
OffsetNumber offnum
Definition: heapam_xlog.h:154
TransactionId old_xmax
Definition: heapam_xlog.h:212
#define XLOG_HEAP_CONFIRM
Definition: heapam_xlog.h:37

◆ heap_execute_freeze_tuple()

void heap_execute_freeze_tuple ( HeapTupleHeader  tuple,
xl_heap_freeze_tuple xlrec_tp 
)

Definition at line 6337 of file heapam.c.

References FrozenTransactionId, xl_heap_freeze_tuple::frzflags, HeapTupleHeaderSetXmax, HeapTupleHeaderSetXvac, InvalidTransactionId, HeapTupleHeaderData::t_infomask, xl_heap_freeze_tuple::t_infomask, HeapTupleHeaderData::t_infomask2, xl_heap_freeze_tuple::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_heap().

6338 {
6339  HeapTupleHeaderSetXmax(tuple, frz->xmax);
6340 
6341  if (frz->frzflags & XLH_FREEZE_XVAC)
6343 
6344  if (frz->frzflags & XLH_INVALID_XVAC)
6346 
6347  tuple->t_infomask = frz->t_infomask;
6348  tuple->t_infomask2 = frz->t_infomask2;
6349 }
#define HeapTupleHeaderSetXvac(tup, xid)
Definition: htup_details.h:423
#define HeapTupleHeaderSetXmax(tup, xid)
Definition: htup_details.h:380
#define InvalidTransactionId
Definition: transam.h:31
#define FrozenTransactionId
Definition: transam.h:33
#define XLH_INVALID_XVAC
Definition: heapam_xlog.h:316
#define XLH_FREEZE_XVAC
Definition: heapam_xlog.h:315

◆ heap_identify()

const char* heap_identify ( uint8  info)

Definition at line 181 of file heapdesc.c.

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.

182 {
183  const char *id = NULL;
184 
185  switch (info & ~XLR_INFO_MASK)
186  {
187  case XLOG_HEAP_INSERT:
188  id = "INSERT";
189  break;
191  id = "INSERT+INIT";
192  break;
193  case XLOG_HEAP_DELETE:
194  id = "DELETE";
195  break;
196  case XLOG_HEAP_UPDATE:
197  id = "UPDATE";
198  break;
200  id = "UPDATE+INIT";
201  break;
203  id = "HOT_UPDATE";
204  break;
206  id = "HOT_UPDATE+INIT";
207  break;
208  case XLOG_HEAP_TRUNCATE:
209  id = "TRUNCATE";
210  break;
211  case XLOG_HEAP_CONFIRM:
212  id = "HEAP_CONFIRM";
213  break;
214  case XLOG_HEAP_LOCK:
215  id = "LOCK";
216  break;
217  case XLOG_HEAP_INPLACE:
218  id = "INPLACE";
219  break;
220  }
221 
222  return id;
223 }
#define XLOG_HEAP_INSERT
Definition: heapam_xlog.h:32
#define XLOG_HEAP_HOT_UPDATE
Definition: heapam_xlog.h:36
#define XLOG_HEAP_INIT_PAGE
Definition: heapam_xlog.h:46
#define XLOG_HEAP_TRUNCATE
Definition: heapam_xlog.h:35
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
#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 XLOG_HEAP_DELETE
Definition: heapam_xlog.h:33
#define XLOG_HEAP_CONFIRM
Definition: heapam_xlog.h:37

◆ heap_mask()

void heap_mask ( char *  pagedata,
BlockNumber  blkno 
)

Definition at line 8907 of file heapam.c.

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

8908 {
8909  Page page = (Page) pagedata;
8910  OffsetNumber off;
8911 
8913 
8914  mask_page_hint_bits(page);
8915  mask_unused_space(page);
8916 
8917  for (off = 1; off <= PageGetMaxOffsetNumber(page); off++)
8918  {
8919  ItemId iid = PageGetItemId(page, off);
8920  char *page_item;
8921 
8922  page_item = (char *) (page + ItemIdGetOffset(iid));
8923 
8924  if (ItemIdIsNormal(iid))
8925  {
8926  HeapTupleHeader page_htup = (HeapTupleHeader) page_item;
8927 
8928  /*
8929  * If xmin of a tuple is not yet frozen, we should ignore
8930  * differences in hint bits, since they can be set without
8931  * emitting WAL.
8932  */
8933  if (!HeapTupleHeaderXminFrozen(page_htup))
8934  page_htup->t_infomask &= ~HEAP_XACT_MASK;
8935  else
8936  {
8937  /* Still we need to mask xmax hint bits. */
8938  page_htup->t_infomask &= ~HEAP_XMAX_INVALID;
8939  page_htup->t_infomask &= ~HEAP_XMAX_COMMITTED;
8940  }
8941 
8942  /*
8943  * During replay, we set Command Id to FirstCommandId. Hence, mask
8944  * it. See heap_xlog_insert() for details.
8945  */
8946  page_htup->t_choice.t_heap.t_field3.t_cid = MASK_MARKER;
8947 
8948  /*
8949  * For a speculative tuple, heap_insert() does not set ctid in the
8950  * caller-passed heap tuple itself, leaving the ctid field to
8951  * contain a speculative token value - a per-backend monotonically
8952  * increasing identifier. Besides, it does not WAL-log ctid under
8953  * any circumstances.
8954  *
8955  * During redo, heap_xlog_insert() sets t_ctid to current block
8956  * number and self offset number. It doesn't care about any
8957  * speculative insertions on the primary. Hence, we set t_ctid to
8958  * current block number and self offset number to ignore any
8959  * inconsistency.
8960  */
8961  if (HeapTupleHeaderIsSpeculative(page_htup))
8962  ItemPointerSet(&page_htup->t_ctid, blkno, off);
8963 
8964  /*
8965  * NB: Not ignoring ctid changes due to the tuple having moved
8966  * (i.e. HeapTupleHeaderIndicatesMovedPartitions), because that's
8967  * important information that needs to be in-sync between primary
8968  * and standby, and thus is WAL logged.
8969  */
8970  }
8971 
8972  /*
8973  * Ignore any padding bytes after the tuple, when the length of the
8974  * item is not MAXALIGNed.
8975  */
8976  if (ItemIdHasStorage(iid))
8977  {
8978  int len = ItemIdGetLength(iid);
8979  int padlen = MAXALIGN(len) - len;
8980 
8981  if (padlen > 0)
8982  memset(page_item + len, MASK_MARKER, padlen);
8983  }
8984  }
8985 }
HeapTupleFields t_heap
Definition: htup_details.h:156
HeapTupleHeaderData * HeapTupleHeader
Definition: htup.h:23
#define HeapTupleHeaderIsSpeculative(tup)
Definition: htup_details.h:429
void mask_page_hint_bits(Page page)
Definition: bufmask.c:46
#define HEAP_XMAX_COMMITTED
Definition: htup_details.h:206
#define PageGetMaxOffsetNumber(page)
Definition: bufpage.h:357
union HeapTupleFields::@43 t_field3
void mask_unused_space(Page page)
Definition: bufmask.c:71
uint16 OffsetNumber
Definition: off.h:24
#define ItemIdGetLength(itemId)
Definition: itemid.h:59
#define MASK_MARKER
Definition: bufmask.h:24
#define HEAP_XMAX_INVALID
Definition: htup_details.h:207
ItemPointerData t_ctid
Definition: htup_details.h:160
#define ItemIdGetOffset(itemId)
Definition: itemid.h:65
#define PageGetItemId(page, offsetNumber)
Definition: bufpage.h:235
void mask_page_lsn_and_checksum(Page page)
Definition: bufmask.c:31
#define HeapTupleHeaderXminFrozen(tup)
Definition: htup_details.h:335
#define ItemIdHasStorage(itemId)
Definition: itemid.h:120
#define ItemIdIsNormal(itemId)
Definition: itemid.h:99
#define MAXALIGN(LEN)
Definition: c.h:698
union HeapTupleHeaderData::@44 t_choice
#define HEAP_XACT_MASK
Definition: htup_details.h:218
CommandId t_cid
Definition: htup_details.h:128
Pointer Page
Definition: bufpage.h:78
#define ItemPointerSet(pointer, blockNumber, offNum)
Definition: itemptr.h:127

◆ 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 
)

Definition at line 6108 of file heapam.c.

References Assert, ereport, errcode(), ERRCODE_DATA_CORRUPTED, errmsg_internal(), ERROR, FreezeMultiXactId(), FRM_INVALIDATE_XMAX, FRM_MARK_COMMITTED, 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, HeapTupleHeaderData::t_infomask, xl_heap_freeze_tuple::t_infomask, HeapTupleHeaderData::t_infomask2, xl_heap_freeze_tuple::t_infomask2, TransactionIdDidCommit(), TransactionIdIsNormal, TransactionIdIsValid, TransactionIdPrecedes(), XLH_FREEZE_XVAC, XLH_INVALID_XVAC, and xl_heap_freeze_tuple::xmax.

Referenced by heap_freeze_tuple(), and lazy_scan_heap().

6112 {
6113  bool changed = false;
6114  bool xmax_already_frozen = false;
6115  bool xmin_frozen;
6116  bool freeze_xmax;
6117  TransactionId xid;
6118 
6119  frz->frzflags = 0;
6120  frz->t_infomask2 = tuple->t_infomask2;
6121  frz->t_infomask = tuple->t_infomask;
6122  frz->xmax = HeapTupleHeaderGetRawXmax(tuple);
6123 
6124  /*
6125  * Process xmin. xmin_frozen has two slightly different meanings: in the
6126  * !XidIsNormal case, it means "the xmin doesn't need any freezing" (it's
6127  * already a permanent value), while in the block below it is set true to
6128  * mean "xmin won't need freezing after what we do to it here" (false
6129  * otherwise). In both cases we're allowed to set totally_frozen, as far
6130  * as xmin is concerned.
6131  */
6132  xid = HeapTupleHeaderGetXmin(tuple);
6133  if (!TransactionIdIsNormal(xid))
6134  xmin_frozen = true;
6135  else
6136  {
6137  if (TransactionIdPrecedes(xid, relfrozenxid))
6138  ereport(ERROR,
6140  errmsg_internal("found xmin %u from before relfrozenxid %u",
6141  xid, relfrozenxid)));
6142 
6143  xmin_frozen = TransactionIdPrecedes(xid, cutoff_xid);
6144  if (xmin_frozen)
6145  {
6146  if (!TransactionIdDidCommit(xid))
6147  ereport(ERROR,
6149  errmsg_internal("uncommitted xmin %u from before xid cutoff %u needs to be frozen",
6150  xid, cutoff_xid)));
6151 
6152  frz->t_infomask |= HEAP_XMIN_FROZEN;
6153  changed = true;
6154  }
6155  }
6156 
6157  /*
6158  * Process xmax. To thoroughly examine the current Xmax value we need to
6159  * resolve a MultiXactId to its member Xids, in case some of them are
6160  * below the given cutoff for Xids. In that case, those values might need
6161  * freezing, too. Also, if a multi needs freezing, we cannot simply take
6162  * it out --- if there's a live updater Xid, it needs to be kept.
6163  *
6164  * Make sure to keep heap_tuple_needs_freeze in sync with this.
6165  */
6166  xid = HeapTupleHeaderGetRawXmax(tuple);
6167 
6168  if (tuple->t_infomask & HEAP_XMAX_IS_MULTI)
6169  {
6170  TransactionId newxmax;
6171  uint16 flags;
6172 
6173  newxmax = FreezeMultiXactId(xid, tuple->t_infomask,
6174  relfrozenxid, relminmxid,
6175  cutoff_xid, cutoff_multi, &flags);
6176 
6177  freeze_xmax = (flags & FRM_INVALIDATE_XMAX);
6178 
6179  if (flags & FRM_RETURN_IS_XID)
6180  {
6181  /*
6182  * NB -- some of these transformations are only valid because we
6183  * know the return Xid is a tuple updater (i.e. not merely a
6184  * locker.) Also note that the only reason we don't explicitly
6185  * worry about HEAP_KEYS_UPDATED is because it lives in
6186  * t_infomask2 rather than t_infomask.
6187  */
6188  frz->t_infomask &= ~HEAP_XMAX_BITS;
6189  frz->xmax = newxmax;
6190  if (flags & FRM_MARK_COMMITTED)
6192  changed = true;
6193  }
6194  else if (flags & FRM_RETURN_IS_MULTI)
6195  {
6196  uint16 newbits;
6197  uint16 newbits2;
6198 
6199  /*
6200  * We can't use GetMultiXactIdHintBits directly on the new multi
6201  * here; that routine initializes the masks to all zeroes, which
6202  * would lose other bits we need. Doing it this way ensures all
6203  * unrelated bits remain untouched.
6204  */
6205  frz->t_infomask &= ~HEAP_XMAX_BITS;
6206  frz->t_infomask2 &= ~HEAP_KEYS_UPDATED;
6207  GetMultiXactIdHintBits(newxmax, &newbits, &newbits2);
6208  frz->t_infomask |= newbits;
6209  frz->t_infomask2 |= newbits2;
6210 
6211  frz->xmax = newxmax;
6212 
6213  changed = true;
6214  }
6215  }
6216  else if (TransactionIdIsNormal(xid))
6217  {
6218  if (TransactionIdPrecedes(xid, relfrozenxid))
6219  ereport(ERROR,
6221  errmsg_internal("found xmax %u from before relfrozenxid %u",
6222  xid, relfrozenxid)));
6223 
6224  if (TransactionIdPrecedes(xid, cutoff_xid))
6225  {
6226  /*
6227  * If we freeze xmax, make absolutely sure that it's not an XID
6228  * that is important. (Note, a lock-only xmax can be removed
6229  * independent of committedness, since a committed lock holder has
6230  * released the lock).
6231  */
6232  if (!HEAP_XMAX_IS_LOCKED_ONLY(tuple->t_infomask) &&
6234  ereport(ERROR,
6236  errmsg_internal("cannot freeze committed xmax %u",
6237  xid)));
6238  freeze_xmax = true;
6239  }
6240  else
6241  freeze_xmax = false;
6242  }
6243  else if ((tuple->t_infomask & HEAP_XMAX_INVALID) ||
6245  {
6246  freeze_xmax = false;
6247  xmax_already_frozen = true;
6248  }
6249  else
6250  ereport(ERROR,
6252  errmsg_internal("found xmax %u (infomask 0x%04x) not frozen, not multi, not normal",
6253  xid, tuple->t_infomask)));
6254 
6255  if (freeze_xmax)
6256  {
6257  Assert(!xmax_already_frozen);
6258 
6259  frz->xmax = InvalidTransactionId;
6260 
6261  /*
6262  * The tuple might be marked either XMAX_INVALID or XMAX_COMMITTED +
6263  * LOCKED. Normalize to INVALID just to be sure no one gets confused.
6264  * Also get rid of the HEAP_KEYS_UPDATED bit.
6265  */
6266  frz->t_infomask &= ~HEAP_XMAX_BITS;
6267  frz->t_infomask |= HEAP_XMAX_INVALID;
6268  frz->t_infomask2 &= ~HEAP_HOT_UPDATED;
6269  frz->t_infomask2 &= ~HEAP_KEYS_UPDATED;
6270  changed = true;
6271  }
6272 
6273  /*
6274  * Old-style VACUUM FULL is gone, but we have to keep this code as long as
6275  * we support having MOVED_OFF/MOVED_IN tuples in the database.
6276  */
6277  if (tuple->t_infomask & HEAP_MOVED)
6278  {
6279  xid = HeapTupleHeaderGetXvac(tuple);
6280 
6281  /*
6282  * For Xvac, we ignore the cutoff_xid and just always perform the
6283  * freeze operation. The oldest release in which such a value can
6284  * actually be set is PostgreSQL 8.4, because old-style VACUUM FULL
6285  * was removed in PostgreSQL 9.0. Note that if we were to respect
6286  * cutoff_xid here, we'd need to make surely to clear totally_frozen
6287  * when we skipped freezing on that basis.
6288  */
6289  if (TransactionIdIsNormal(xid))
6290  {
6291  /*
6292  * If a MOVED_OFF tuple is not dead, the xvac transaction must
6293  * have failed; whereas a non-dead MOVED_IN tuple must mean the
6294  * xvac transaction succeeded.
6295  */
6296  if (tuple->t_infomask & HEAP_MOVED_OFF)
6297  frz->frzflags |= XLH_INVALID_XVAC;
6298  else
6299  frz->frzflags |= XLH_FREEZE_XVAC;
6300 
6301  /*
6302  * Might as well fix the hint bits too; usually XMIN_COMMITTED
6303  * will already be set here, but there's a small chance not.
6304  */
6305  Assert(!(tuple->t_infomask & HEAP_XMIN_INVALID));
6307  changed = true;
6308  }
6309  }
6310 
6311  *totally_frozen_p = (xmin_frozen &&
6312  (freeze_xmax || xmax_already_frozen));
6313  return changed;
6314 }
#define FRM_RETURN_IS_XID
Definition: heapam.c:5782
static void GetMultiXactIdHintBits(MultiXactId multi, uint16 *new_infomask, uint16 *new_infomask2)
Definition: heapam.c:6389
#define FRM_MARK_COMMITTED
Definition: heapam.c:5784
#define HEAP_XMAX_BITS
Definition: htup_details.h:270
uint32 TransactionId
Definition: c.h:520
#define HEAP_XMIN_FROZEN
Definition: htup_details.h:205
int errcode(int sqlerrcode)
Definition: elog.c:610
#define HEAP_XMAX_COMMITTED
Definition: htup_details.h:206
bool TransactionIdDidCommit(TransactionId transactionId)
Definition: transam.c:125
#define HEAP_XMIN_INVALID
Definition: htup_details.h:204
#define HeapTupleHeaderGetRawXmax(tup)
Definition: htup_details.h:375
unsigned short uint16
Definition: c.h:373
#define ERROR
Definition: elog.h:43
#define HEAP_XMAX_INVALID
Definition: htup_details.h:207
#define FRM_INVALIDATE_XMAX
Definition: heapam.c:5781
#define InvalidTransactionId
Definition: transam.h:31
#define HeapTupleHeaderGetXvac(tup)
Definition: htup_details.h:415
bool TransactionIdPrecedes(TransactionId id1, TransactionId id2)
Definition: transam.c:300
#define ERRCODE_DATA_CORRUPTED
Definition: pg_basebackup.c:45
#define FRM_RETURN_IS_MULTI
Definition: heapam.c:5783
#define HEAP_XMAX_IS_LOCKED_ONLY(infomask)
Definition: htup_details.h:230
#define HEAP_KEYS_UPDATED
Definition: htup_details.h:278
#define HEAP_XMAX_IS_MULTI
Definition: htup_details.h:208
#define HEAP_XMIN_COMMITTED
Definition: htup_details.h:203
#define HEAP_MOVED
Definition: htup_details.h:216
#define ereport(elevel,...)
Definition: elog.h:144
int errmsg_internal(const char *fmt,...)
Definition: elog.c:911
#define HEAP_MOVED_OFF
Definition: htup_details.h:210
#define Assert(condition)
Definition: c.h:745
#define HeapTupleHeaderGetXmin(tup)
Definition: htup_details.h:313
TransactionId xmax
Definition: heapam_xlog.h:320
static TransactionId FreezeMultiXactId(MultiXactId multi, uint16 t_infomask, TransactionId relfrozenxid, TransactionId relminmxid, TransactionId cutoff_xid, MultiXactId cutoff_multi, uint16 *flags)
Definition: heapam.c:5808
#define HEAP_HOT_UPDATED
Definition: htup_details.h:280
#define XLH_INVALID_XVAC
Definition: heapam_xlog.h:316
#define TransactionIdIsValid(xid)
Definition: transam.h:41
#define TransactionIdIsNormal(xid)
Definition: transam.h:42
#define XLH_FREEZE_XVAC
Definition: heapam_xlog.h:315

◆ heap_redo()

void heap_redo ( XLogReaderState record)

Definition at line 8818 of file heapam.c.

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.

8819 {
8820  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
8821 
8822  /*
8823  * These operations don't overwrite MVCC data so no conflict processing is
8824  * required. The ones in heap2 rmgr do.
8825  */
8826 
8827  switch (info & XLOG_HEAP_OPMASK)
8828  {
8829  case XLOG_HEAP_INSERT:
8830  heap_xlog_insert(record);
8831  break;
8832  case XLOG_HEAP_DELETE:
8833  heap_xlog_delete(record);
8834  break;
8835  case XLOG_HEAP_UPDATE:
8836  heap_xlog_update(record, false);
8837  break;
8838  case XLOG_HEAP_TRUNCATE:
8839 
8840  /*
8841  * TRUNCATE is a no-op because the actions are already logged as
8842  * SMGR WAL records. TRUNCATE WAL record only exists for logical
8843  * decoding.
8844  */
8845  break;
8846  case XLOG_HEAP_HOT_UPDATE:
8847  heap_xlog_update(record, true);
8848  break;
8849  case XLOG_HEAP_CONFIRM:
8850  heap_xlog_confirm(record);
8851  break;
8852  case XLOG_HEAP_LOCK:
8853  heap_xlog_lock(record);
8854  break;
8855  case XLOG_HEAP_INPLACE:
8856  heap_xlog_inplace(record);
8857  break;
8858  default:
8859  elog(PANIC, "heap_redo: unknown op code %u", info);
8860  }
8861 }
#define XLOG_HEAP_INSERT
Definition: heapam_xlog.h:32
unsigned char uint8
Definition: c.h:372
#define XLOG_HEAP_OPMASK
Definition: heapam_xlog.h:41
#define XLOG_HEAP_HOT_UPDATE
Definition: heapam_xlog.h:36
#define PANIC
Definition: elog.h:53
static void heap_xlog_confirm(XLogReaderState *record)
Definition: heapam.c:8610
static void heap_xlog_lock(XLogReaderState *record)
Definition: heapam.c:8646
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:305
#define XLOG_HEAP_TRUNCATE
Definition: heapam_xlog.h:35
static void heap_xlog_insert(XLogReaderState *record)
Definition: heapam.c:8083
static void heap_xlog_inplace(XLogReaderState *record)
Definition: heapam.c:8777
static void heap_xlog_delete(XLogReaderState *record)
Definition: heapam.c:8010
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
#define XLOG_HEAP_UPDATE
Definition: heapam_xlog.h:34
#define XLOG_HEAP_INPLACE
Definition: heapam_xlog.h:39
static void heap_xlog_update(XLogReaderState *record, bool hot_update)
Definition: heapam.c:8338
#define XLOG_HEAP_LOCK
Definition: heapam_xlog.h:38
#define elog(elevel,...)
Definition: elog.h:214
#define XLOG_HEAP_DELETE
Definition: heapam_xlog.h:33
#define XLOG_HEAP_CONFIRM
Definition: heapam_xlog.h:37

◆ heap_xlog_logical_rewrite()

void heap_xlog_logical_rewrite ( XLogReaderState r)

Definition at line 1112 of file rewriteheap.c.

References CloseTransientFile(), data_sync_elevel(), ereport, errcode_for_file_access(), errmsg(), ERROR, fd(), ftruncate, LOGICAL_REWRITE_FORMAT, 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().

1113 {
1114  char path[MAXPGPATH];
1115  int fd;
1116  xl_heap_rewrite_mapping *xlrec;
1117  uint32 len;
1118  char *data;
1119 
1120  xlrec = (xl_heap_rewrite_mapping *) XLogRecGetData(r);
1121 
1122  snprintf(path, MAXPGPATH,
1123  "pg_logical/mappings/" LOGICAL_REWRITE_FORMAT,
1124  xlrec->mapped_db, xlrec->mapped_rel,
1125  (uint32) (xlrec->start_lsn >> 32),
1126  (uint32) xlrec->start_lsn,
1127  xlrec->mapped_xid, XLogRecGetXid(r));
1128 
1129  fd = OpenTransientFile(path,
1130  O_CREAT | O_WRONLY | PG_BINARY);
1131  if (fd < 0)
1132  ereport(ERROR,
1134  errmsg("could not create file \"%s\": %m", path)));
1135 
1136  /*
1137  * Truncate all data that's not guaranteed to have been safely fsynced (by
1138  * previous record or by the last checkpoint).
1139  */
1141  if (ftruncate(fd, xlrec->offset) != 0)
1142  ereport(ERROR,
1144  errmsg("could not truncate file \"%s\" to %u: %m",
1145  path, (uint32) xlrec->offset)));
1147 
1148  data = XLogRecGetData(r) + sizeof(*xlrec);
1149 
1150  len = xlrec->num_mappings * sizeof(LogicalRewriteMappingData);
1151 
1152  /* write out tail end of mapping file (again) */
1153  errno = 0;
1155  if (pg_pwrite(fd, data, len, xlrec->offset) != len)
1156  {
1157  /* if write didn't set errno, assume problem is no disk space */
1158  if (errno == 0)
1159  errno = ENOSPC;
1160  ereport(ERROR,
1162  errmsg("could not write to file \"%s\": %m", path)));
1163  }
1165 
1166  /*
1167  * Now fsync all previously written data. We could improve things and only
1168  * do this for the last write to a file, but the required bookkeeping
1169  * doesn't seem worth the trouble.
1170  */
1172  if (pg_fsync(fd) != 0)
1175  errmsg("could not fsync file \"%s\": %m", path)));
1177 
1178  if (CloseTransientFile(fd) != 0)
1179  ereport(ERROR,
1181  errmsg("could not close file \"%s\": %m", path)));
1182 }
static int fd(const char *x, int i)
Definition: preproc-init.c:105
#define PG_BINARY
Definition: c.h:1240
ssize_t pg_pwrite(int fd, const void *buf, size_t nbyte, off_t offset)
Definition: pwrite.c:27
#define XLogRecGetData(decoder)
Definition: xlogreader.h:310
#define ERROR
Definition: elog.h:43
int OpenTransientFile(const char *fileName, int fileFlags)
Definition: fd.c:2372
#define MAXPGPATH
int errcode_for_file_access(void)
Definition: elog.c:633
unsigned int uint32
Definition: c.h:374
static void pgstat_report_wait_end(void)
Definition: pgstat.h:1381
int CloseTransientFile(int fd)
Definition: fd.c:2549
#define XLogRecGetXid(decoder)
Definition: xlogreader.h:307
int data_sync_elevel(int elevel)
Definition: fd.c:3605
#define ereport(elevel,...)
Definition: elog.h:144
TransactionId mapped_xid
Definition: heapam_xlog.h:378
static void pgstat_report_wait_start(uint32 wait_event_info)
Definition: pgstat.h:1357
#define LOGICAL_REWRITE_FORMAT
Definition: rewriteheap.h:54
int errmsg(const char *fmt,...)
Definition: elog.c:824
struct LogicalRewriteMappingData LogicalRewriteMappingData
int pg_fsync(int fd)
Definition: fd.c:345
#define snprintf
Definition: port.h:193
#define ftruncate(a, b)
Definition: win32_port.h:59

◆ HeapTupleHeaderAdvanceLatestRemovedXid()

void HeapTupleHeaderAdvanceLatestRemovedXid ( HeapTupleHeader  tuple,
TransactionId latestRemovedXid 
)

Definition at line 6885 of file heapam.c.

References HEAP_MOVED, HeapTupleHeaderGetUpdateXid, HeapTupleHeaderGetXmin, HeapTupleHeaderGetXvac, HeapTupleHeaderXminCommitted, HeapTupleHeaderXminInvalid, i, InvalidBlockNumber, ItemPointerGetBlockNumber, MAIN_FORKNUM, PrefetchBuffer(), HeapTupleHeaderData::t_infomask, TransactionIdDidCommit(), TransactionIdFollows(), and TransactionIdPrecedes().

Referenced by heap_compute_xid_horizon_for_tuples(), heap_prune_chain(), and lazy_scan_heap().

6887 {
6888  TransactionId xmin = HeapTupleHeaderGetXmin(tuple);
6890  TransactionId xvac = HeapTupleHeaderGetXvac(tuple);
6891 
6892  if (tuple->t_infomask & HEAP_MOVED)
6893  {
6894  if (TransactionIdPrecedes(*latestRemovedXid, xvac))
6895  *latestRemovedXid = xvac;
6896  }
6897 
6898  /*
6899  * Ignore tuples inserted by an aborted transaction or if the tuple was
6900  * updated/deleted by the inserting transaction.
6901  *
6902  * Look for a committed hint bit, or if no xmin bit is set, check clog.
6903  * This needs to work on both primary and standby, where it is used to
6904  * assess btree delete records.
6905  */
6906  if (HeapTupleHeaderXminCommitted(tuple) ||
6908  {
6909  if (xmax != xmin &&
6910  TransactionIdFollows(xmax, *latestRemovedXid))
6911  *latestRemovedXid = xmax;
6912  }
6913 
6914  /* *latestRemovedXid may still be invalid at end */
6915 }
#define HeapTupleHeaderGetUpdateXid(tup)
Definition: htup_details.h:365
bool TransactionIdFollows(TransactionId id1, TransactionId id2)
Definition: transam.c:334
uint32 TransactionId
Definition: c.h:520
#define HeapTupleHeaderXminInvalid(tup)
Definition: htup_details.h:329
bool TransactionIdDidCommit(TransactionId transactionId)
Definition: transam.c:125
#define HeapTupleHeaderXminCommitted(tup)
Definition: htup_details.h:324
#define HeapTupleHeaderGetXvac(tup)
Definition: htup_details.h:415
bool TransactionIdPrecedes(TransactionId id1, TransactionId id2)
Definition: transam.c:300
#define HEAP_MOVED
Definition: htup_details.h:216
#define HeapTupleHeaderGetXmin(tup)
Definition: htup_details.h:313

◆ log_heap_clean()

XLogRecPtr log_heap_clean ( Relation  reln,
Buffer  buffer,
OffsetNumber redirected,
int  nredirected,
OffsetNumber nowdead,
int  ndead,
OffsetNumber nowunused,
int  nunused,
TransactionId  latestRemovedXid 
)

Definition at line 7157 of file heapam.c.

References Assert, xl_heap_clean::latestRemovedXid, xl_heap_clean::ndead, xl_heap_clean::nredirected, REGBUF_STANDARD, RelationNeedsWAL, SizeOfHeapClean, XLOG_HEAP2_CLEAN, XLogBeginInsert(), XLogInsert(), XLogRegisterBufData(), XLogRegisterBuffer(), and XLogRegisterData().

Referenced by heap_page_prune(), and lazy_vacuum_page().

7162 {
7163  xl_heap_clean xlrec;
7164  XLogRecPtr recptr;
7165 
7166  /* Caller should not call me on a non-WAL-logged relation */
7167  Assert(RelationNeedsWAL(reln));
7168 
7169  xlrec.latestRemovedXid = latestRemovedXid;
7170  xlrec.nredirected = nredirected;
7171  xlrec.ndead = ndead;
7172 
7173  XLogBeginInsert();
7174  XLogRegisterData((char *) &xlrec, SizeOfHeapClean);
7175 
7176  XLogRegisterBuffer(0, buffer, REGBUF_STANDARD);
7177 
7178  /*
7179  * The OffsetNumber arrays are not actually in the buffer, but we pretend
7180  * that they are. When XLogInsert stores the whole buffer, the offset
7181  * arrays need not be stored too. Note that even if all three arrays are
7182  * empty, we want to expose the buffer as a candidate for whole-page
7183  * storage, since this record type implies a defragmentation operation
7184  * even if no line pointers changed state.
7185  */
7186  if (nredirected > 0)
7187  XLogRegisterBufData(0, (char *) redirected,
7188  nredirected * sizeof(OffsetNumber) * 2);
7189 
7190  if (ndead > 0)
7191  XLogRegisterBufData(0, (char *) nowdead,
7192  ndead * sizeof(OffsetNumber));
7193 
7194  if (nunused > 0)
7195  XLogRegisterBufData(0, (char *) nowunused,
7196  nunused * sizeof(OffsetNumber));
7197 
7198  recptr = XLogInsert(RM_HEAP2_ID, XLOG_HEAP2_CLEAN);
7199 
7200  return recptr;
7201 }
void XLogRegisterBufData(uint8 block_id, char *data, int len)
Definition: xloginsert.c:368
uint16 nredirected
Definition: heapam_xlog.h:241
void XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags)
Definition: xloginsert.c:220
uint16 OffsetNumber
Definition: off.h:24
#define SizeOfHeapClean
Definition: heapam_xlog.h:246
#define XLOG_HEAP2_CLEAN
Definition: heapam_xlog.h:54
#define REGBUF_STANDARD
Definition: xloginsert.h:35
void XLogRegisterData(char *data, int len)
Definition: xloginsert.c:330
XLogRecPtr XLogInsert(RmgrId rmid, uint8 info)
Definition: xloginsert.c:422
uint64 XLogRecPtr
Definition: xlogdefs.h:21
#define Assert(condition)
Definition: c.h:745
#define RelationNeedsWAL(relation)
Definition: rel.h:562
TransactionId latestRemovedXid
Definition: heapam_xlog.h:240
void XLogBeginInsert(void)
Definition: xloginsert.c:123

◆ log_heap_cleanup_info()

XLogRecPtr log_heap_cleanup_info ( RelFileNode  rnode,
TransactionId  latestRemovedXid 
)

Definition at line 7128 of file heapam.c.

References xl_heap_cleanup_info::latestRemovedXid, xl_heap_cleanup_info::node, SizeOfHeapCleanupInfo, XLOG_HEAP2_CLEANUP_INFO, XLogBeginInsert(), XLogInsert(), and XLogRegisterData().

Referenced by vacuum_log_cleanup_info().

7129 {
7130  xl_heap_cleanup_info xlrec;
7131  XLogRecPtr recptr;
7132 
7133  xlrec.node = rnode;
7134  xlrec.latestRemovedXid = latestRemovedXid;
7135 
7136  XLogBeginInsert();
7137  XLogRegisterData((char *) &xlrec, SizeOfHeapCleanupInfo);
7138 
7139  recptr = XLogInsert(RM_HEAP2_ID, XLOG_HEAP2_CLEANUP_INFO);
7140 
7141  return recptr;
7142 }
#define SizeOfHeapCleanupInfo
Definition: heapam_xlog.h:259
#define XLOG_HEAP2_CLEANUP_INFO
Definition: heapam_xlog.h:56
void XLogRegisterData(char *data, int len)
Definition: xloginsert.c:330
XLogRecPtr XLogInsert(RmgrId rmid, uint8 info)
Definition: xloginsert.c:422
uint64 XLogRecPtr
Definition: xlogdefs.h:21
void XLogBeginInsert(void)
Definition: xloginsert.c:123
TransactionId latestRemovedXid
Definition: heapam_xlog.h:256

◆ log_heap_freeze()

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

Definition at line 7208 of file heapam.c.

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_heap().

7210 {
7211  xl_heap_freeze_page xlrec;
7212  XLogRecPtr recptr;
7213 
7214  /* Caller should not call me on a non-WAL-logged relation */
7215  Assert(RelationNeedsWAL(reln));
7216  /* nor when there are no tuples to freeze */
7217  Assert(ntuples > 0);
7218 
7219  xlrec.cutoff_xid = cutoff_xid;
7220  xlrec.ntuples = ntuples;
7221 
7222  XLogBeginInsert();
7223  XLogRegisterData((char *) &xlrec, SizeOfHeapFreezePage);
7224 
7225  /*
7226  * The freeze plan array is not actually in the buffer, but pretend that
7227  * it is. When XLogInsert stores the whole buffer, the freeze plan need
7228  * not be stored too.
7229  */
7230  XLogRegisterBuffer(0, buffer, REGBUF_STANDARD);
7231  XLogRegisterBufData(0, (char *) tuples,
7232  ntuples * sizeof(xl_heap_freeze_tuple));
7233 
7234  recptr = XLogInsert(RM_HEAP2_ID, XLOG_HEAP2_FREEZE_PAGE);
7235 
7236  return recptr;
7237 }
void XLogRegisterBufData(uint8 block_id, char *data, int len)
Definition: xloginsert.c:368
void XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags)
Definition: xloginsert.c:220
TransactionId cutoff_xid
Definition: heapam_xlog.h:335
#define SizeOfHeapFreezePage
Definition: heapam_xlog.h:339
#define REGBUF_STANDARD
Definition: xloginsert.h:35
void XLogRegisterData(char *data, int len)
Definition: xloginsert.c:330
XLogRecPtr XLogInsert(RmgrId rmid, uint8 info)
Definition: xloginsert.c:422
uint64 XLogRecPtr
Definition: xlogdefs.h:21
#define Assert(condition)
Definition: c.h:745
#define RelationNeedsWAL(relation)
Definition: rel.h:562
#define XLOG_HEAP2_FREEZE_PAGE
Definition: heapam_xlog.h:55
void XLogBeginInsert(void)
Definition: xloginsert.c:123

◆ log_heap_visible()

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

Definition at line 7249 of file heapam.c.

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().

7251 {
7252  xl_heap_visible xlrec;
7253  XLogRecPtr recptr;
7254  uint8 flags;
7255 
7256  Assert(BufferIsValid(heap_buffer));
7257  Assert(BufferIsValid(vm_buffer));
7258 
7259  xlrec.cutoff_xid = cutoff_xid;
7260  xlrec.flags = vmflags;
7261  XLogBeginInsert();
7262  XLogRegisterData((char *) &xlrec, SizeOfHeapVisible);
7263 
7264  XLogRegisterBuffer(0, vm_buffer, 0);
7265 
7266  flags = REGBUF_STANDARD;
7267  if (!XLogHintBitIsNeeded())
7268  flags |= REGBUF_NO_IMAGE;
7269  XLogRegisterBuffer(1, heap_buffer, flags);
7270 
7271  recptr = XLogInsert(RM_HEAP2_ID, XLOG_HEAP2_VISIBLE);
7272 
7273  return recptr;
7274 }
void XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags)
Definition: xloginsert.c:220
unsigned char uint8
Definition: c.h:372
#define XLOG_HEAP2_VISIBLE
Definition: heapam_xlog.h:57
TransactionId cutoff_xid
Definition: heapam_xlog.h:349
#define REGBUF_STANDARD
Definition: xloginsert.h:35
void XLogRegisterData(char *data, int len)
Definition: xloginsert.c:330
XLogRecPtr XLogInsert(RmgrId rmid, uint8 info)
Definition: xloginsert.c:422
#define SizeOfHeapVisible
Definition: heapam_xlog.h:353
uint64 XLogRecPtr
Definition: xlogdefs.h:21
#define Assert(condition)
Definition: c.h:745
#define REGBUF_NO_IMAGE
Definition: xloginsert.h:32
#define BufferIsValid(bufnum)
Definition: bufmgr.h:123
void XLogBeginInsert(void)
Definition: xloginsert.c:123
#define XLogHintBitIsNeeded()
Definition: xlog.h:202