PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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_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_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_CONTAINS_OLD   (XLH_DELETE_CONTAINS_OLD_TUPLE | XLH_DELETE_CONTAINS_OLD_KEY)
 
#define SizeOfHeapDelete   (offsetof(xl_heap_delete, flags) + sizeof(uint8))
 
#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_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 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

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

Definition at line 224 of file heapam_xlog.h.

Referenced by log_heap_clean().

#define SizeOfHeapCleanupInfo   (sizeof(xl_heap_cleanup_info))

Definition at line 237 of file heapam_xlog.h.

Referenced by log_heap_cleanup_info().

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

Definition at line 277 of file heapam_xlog.h.

Referenced by heap_finish_speculative().

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

Definition at line 110 of file heapam_xlog.h.

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

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

Definition at line 317 of file heapam_xlog.h.

Referenced by log_heap_freeze().

#define SizeOfHeapHeader   (offsetof(xl_heap_header, t_hoff) + sizeof(uint8))
#define SizeOfHeapInplace   (offsetof(xl_heap_inplace, offnum) + sizeof(OffsetNumber))

Definition at line 286 of file heapam_xlog.h.

Referenced by heap_inplace_update().

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

Definition at line 138 of file heapam_xlog.h.

Referenced by heap_insert().

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

Definition at line 258 of file heapam_xlog.h.

Referenced by heap_lock_tuple(), and heap_update().

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

Definition at line 269 of file heapam_xlog.h.

Referenced by heap_lock_updated_tuple_rec().

#define SizeOfHeapMultiInsert   offsetof(xl_heap_multi_insert, offsets)

Definition at line 158 of file heapam_xlog.h.

Referenced by heap_multi_insert().

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

Definition at line 357 of file heapam_xlog.h.

Referenced by log_heap_new_cid().

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

Definition at line 203 of file heapam_xlog.h.

Referenced by DecodeUpdate(), and log_heap_update().

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

Definition at line 331 of file heapam_xlog.h.

Referenced by log_heap_visible().

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

Definition at line 169 of file heapam_xlog.h.

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

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

#define XLH_DELETE_CONTAINS_OLD   (XLH_DELETE_CONTAINS_OLD_TUPLE | XLH_DELETE_CONTAINS_OLD_KEY)

Definition at line 98 of file heapam_xlog.h.

Referenced by DecodeDelete().

#define XLH_DELETE_CONTAINS_OLD_KEY   (1<<2)

Definition at line 94 of file heapam_xlog.h.

Referenced by heap_delete().

#define XLH_DELETE_CONTAINS_OLD_TUPLE   (1<<1)

Definition at line 93 of file heapam_xlog.h.

Referenced by heap_delete().

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

#define XLH_FREEZE_XVAC   0x02

Definition at line 293 of file heapam_xlog.h.

Referenced by heap_execute_freeze_tuple(), and heap_prepare_freeze_tuple().

#define XLH_INSERT_ALL_VISIBLE_CLEARED   (1<<0)
#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().

#define XLH_INSERT_IS_SPECULATIVE   (1<<2)

Definition at line 68 of file heapam_xlog.h.

Referenced by DecodeInsert(), and heap_insert().

#define XLH_INSERT_LAST_IN_MULTI   (1<<1)

Definition at line 67 of file heapam_xlog.h.

Referenced by DecodeMultiInsert(), and heap_multi_insert().

#define XLH_INVALID_XVAC   0x04

Definition at line 294 of file heapam_xlog.h.

Referenced by heap_execute_freeze_tuple(), and heap_prepare_freeze_tuple().

#define XLH_LOCK_ALL_FROZEN_CLEARED   0x01
#define XLH_UPDATE_CONTAINS_NEW_TUPLE   (1<<4)

Definition at line 80 of file heapam_xlog.h.

Referenced by DecodeUpdate(), and log_heap_update().

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

#define XLH_UPDATE_CONTAINS_OLD_KEY   (1<<3)

Definition at line 79 of file heapam_xlog.h.

Referenced by log_heap_update().

#define XLH_UPDATE_CONTAINS_OLD_TUPLE   (1<<2)

Definition at line 78 of file heapam_xlog.h.

Referenced by log_heap_update().

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

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

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

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

#define XLHL_KEYS_UPDATED   0x10

Definition at line 244 of file heapam_xlog.h.

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

#define XLHL_XMAX_EXCL_LOCK   0x04

Definition at line 242 of file heapam_xlog.h.

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

#define XLHL_XMAX_IS_MULTI   0x01

Definition at line 240 of file heapam_xlog.h.

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

#define XLHL_XMAX_KEYSHR_LOCK   0x08

Definition at line 243 of file heapam_xlog.h.

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

#define XLHL_XMAX_LOCK_ONLY   0x02

Definition at line 241 of file heapam_xlog.h.

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

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

#define XLOG_HEAP2_CLEANUP_INFO   0x30
#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().

#define XLOG_HEAP2_LOCK_UPDATED   0x60
#define XLOG_HEAP2_MULTI_INSERT   0x50
#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().

#define XLOG_HEAP2_REWRITE   0x00
#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().

#define XLOG_HEAP_CONFIRM   0x50
#define XLOG_HEAP_DELETE   0x10
#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().

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

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

#define XLOG_HEAP_LOCK   0x60
#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().

#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

Function Documentation

void heap2_desc ( StringInfo  buf,
XLogReaderState record 
)

Definition at line 100 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_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.

101 {
102  char *rec = XLogRecGetData(record);
103  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
104 
105  info &= XLOG_HEAP_OPMASK;
106  if (info == XLOG_HEAP2_CLEAN)
107  {
108  xl_heap_clean *xlrec = (xl_heap_clean *) rec;
109 
110  appendStringInfo(buf, "remxid %u", xlrec->latestRemovedXid);
111  }
112  else if (info == XLOG_HEAP2_FREEZE_PAGE)
113  {
114  xl_heap_freeze_page *xlrec = (xl_heap_freeze_page *) rec;
115 
116  appendStringInfo(buf, "cutoff xid %u ntuples %u",
117  xlrec->cutoff_xid, xlrec->ntuples);
118  }
119  else if (info == XLOG_HEAP2_CLEANUP_INFO)
120  {
122 
123  appendStringInfo(buf, "remxid %u", xlrec->latestRemovedXid);
124  }
125  else if (info == XLOG_HEAP2_VISIBLE)
126  {
127  xl_heap_visible *xlrec = (xl_heap_visible *) rec;
128 
129  appendStringInfo(buf, "cutoff xid %u flags %d",
130  xlrec->cutoff_xid, xlrec->flags);
131  }
132  else if (info == XLOG_HEAP2_MULTI_INSERT)
133  {
135 
136  appendStringInfo(buf, "%d tuples", xlrec->ntuples);
137  }
138  else if (info == XLOG_HEAP2_LOCK_UPDATED)
139  {
141 
142  appendStringInfo(buf, "off %u: xmax %u: flags %u ",
143  xlrec->offnum, xlrec->xmax, xlrec->flags);
144  out_infobits(buf, xlrec->infobits_set);
145  }
146  else if (info == XLOG_HEAP2_NEW_CID)
147  {
148  xl_heap_new_cid *xlrec = (xl_heap_new_cid *) rec;
149 
150  appendStringInfo(buf, "rel %u/%u/%u; tid %u/%u",
151  xlrec->target_node.spcNode,
152  xlrec->target_node.dbNode,
153  xlrec->target_node.relNode,
156  appendStringInfo(buf, "; cmin: %u, cmax: %u, combo: %u",
157  xlrec->cmin, xlrec->cmax, xlrec->combocid);
158  }
159 }
#define XLOG_HEAP2_LOCK_UPDATED
Definition: heapam_xlog.h:59
CommandId combocid
Definition: heapam_xlog.h:348
TransactionId cutoff_xid
Definition: heapam_xlog.h:313
unsigned char uint8
Definition: c.h:266
#define XLOG_HEAP_OPMASK
Definition: heapam_xlog.h:41
CommandId cmax
Definition: heapam_xlog.h:341
ItemPointerData target_tid
Definition: heapam_xlog.h:354
OffsetNumber offnum
Definition: heapam_xlog.h:264
#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:220
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:78
TransactionId cutoff_xid
Definition: heapam_xlog.h:327
#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:263
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:216
RelFileNode target_node
Definition: heapam_xlog.h:353
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
#define ItemPointerGetOffsetNumber(pointer)
Definition: itemptr.h:95
#define XLOG_HEAP2_FREEZE_PAGE
Definition: heapam_xlog.h:55
TransactionId latestRemovedXid
Definition: heapam_xlog.h:218
CommandId cmin
Definition: heapam_xlog.h:340
#define ItemPointerGetBlockNumber(pointer)
Definition: itemptr.h:76
TransactionId latestRemovedXid
Definition: heapam_xlog.h:234
const char* heap2_identify ( uint8  info)

Definition at line 204 of file heapdesc.c.

References NULL, 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.

205 {
206  const char *id = NULL;
207 
208  switch (info & ~XLR_INFO_MASK)
209  {
210  case XLOG_HEAP2_CLEAN:
211  id = "CLEAN";
212  break;
214  id = "FREEZE_PAGE";
215  break;
217  id = "CLEANUP_INFO";
218  break;
219  case XLOG_HEAP2_VISIBLE:
220  id = "VISIBLE";
221  break;
223  id = "MULTI_INSERT";
224  break;
226  id = "MULTI_INSERT+INIT";
227  break;
229  id = "LOCK_UPDATED";
230  break;
231  case XLOG_HEAP2_NEW_CID:
232  id = "NEW_CID";
233  break;
234  case XLOG_HEAP2_REWRITE:
235  id = "REWRITE";
236  break;
237  }
238 
239  return id;
240 }
#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 NULL
Definition: c.h:229
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
#define XLOG_HEAP2_FREEZE_PAGE
Definition: heapam_xlog.h:55
void heap2_redo ( XLogReaderState record)

Definition at line 9030 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.

9031 {
9032  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
9033 
9034  switch (info & XLOG_HEAP_OPMASK)
9035  {
9036  case XLOG_HEAP2_CLEAN:
9037  heap_xlog_clean(record);
9038  break;
9040  heap_xlog_freeze_page(record);
9041  break;
9043  heap_xlog_cleanup_info(record);
9044  break;
9045  case XLOG_HEAP2_VISIBLE:
9046  heap_xlog_visible(record);
9047  break;
9049  heap_xlog_multi_insert(record);
9050  break;
9052  heap_xlog_lock_updated(record);
9053  break;
9054  case XLOG_HEAP2_NEW_CID:
9055 
9056  /*
9057  * Nothing to do on a real replay, only used during logical
9058  * decoding.
9059  */
9060  break;
9061  case XLOG_HEAP2_REWRITE:
9062  heap_xlog_logical_rewrite(record);
9063  break;
9064  default:
9065  elog(PANIC, "heap2_redo: unknown op code %u", info);
9066  }
9067 }
void heap_xlog_logical_rewrite(XLogReaderState *r)
Definition: rewriteheap.c:1118
#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:266
#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:8891
static void heap_xlog_freeze_page(XLogReaderState *record)
Definition: heapam.c:8108
#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:8373
#define XLOG_HEAP2_NEW_CID
Definition: heapam_xlog.h:60
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:216
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
static void heap_xlog_cleanup_info(XLogReaderState *record)
Definition: heapam.c:7882
#define XLOG_HEAP2_FREEZE_PAGE
Definition: heapam_xlog.h:55
static void heap_xlog_visible(XLogReaderState *record)
Definition: heapam.c:7993
#define elog
Definition: elog.h:219
static void heap_xlog_clean(XLogReaderState *record)
Definition: heapam.c:7903
void heap_desc ( StringInfo  buf,
XLogReaderState record 
)

Definition at line 35 of file heapdesc.c.

References appendStringInfo(), xl_heap_lock::flags, 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_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(), XLOG_HEAP_CONFIRM, XLOG_HEAP_DELETE, XLOG_HEAP_HOT_UPDATE, XLOG_HEAP_INPLACE, XLOG_HEAP_INSERT, XLOG_HEAP_LOCK, XLOG_HEAP_OPMASK, 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", xlrec->offnum);
46  }
47  else if (info == XLOG_HEAP_DELETE)
48  {
49  xl_heap_delete *xlrec = (xl_heap_delete *) rec;
50 
51  appendStringInfo(buf, "off %u ", xlrec->offnum);
52  out_infobits(buf, xlrec->infobits_set);
53  }
54  else if (info == XLOG_HEAP_UPDATE)
55  {
56  xl_heap_update *xlrec = (xl_heap_update *) rec;
57 
58  appendStringInfo(buf, "off %u xmax %u ",
59  xlrec->old_offnum,
60  xlrec->old_xmax);
61  out_infobits(buf, xlrec->old_infobits_set);
62  appendStringInfo(buf, "; new off %u xmax %u",
63  xlrec->new_offnum,
64  xlrec->new_xmax);
65  }
66  else if (info == XLOG_HEAP_HOT_UPDATE)
67  {
68  xl_heap_update *xlrec = (xl_heap_update *) rec;
69 
70  appendStringInfo(buf, "off %u xmax %u ",
71  xlrec->old_offnum,
72  xlrec->old_xmax);
73  out_infobits(buf, xlrec->old_infobits_set);
74  appendStringInfo(buf, "; new off %u xmax %u",
75  xlrec->new_offnum,
76  xlrec->new_xmax);
77  }
78  else if (info == XLOG_HEAP_CONFIRM)
79  {
80  xl_heap_confirm *xlrec = (xl_heap_confirm *) rec;
81 
82  appendStringInfo(buf, "off %u", xlrec->offnum);
83  }
84  else if (info == XLOG_HEAP_LOCK)
85  {
86  xl_heap_lock *xlrec = (xl_heap_lock *) rec;
87 
88  appendStringInfo(buf, "off %u: xid %u: flags %u ",
89  xlrec->offnum, xlrec->locking_xid, xlrec->flags);
90  out_infobits(buf, xlrec->infobits_set);
91  }
92  else if (info == XLOG_HEAP_INPLACE)
93  {
94  xl_heap_inplace *xlrec = (xl_heap_inplace *) rec;
95 
96  appendStringInfo(buf, "off %u", xlrec->offnum);
97  }
98 }
#define XLOG_HEAP_INSERT
Definition: heapam_xlog.h:32
uint8 old_infobits_set
Definition: heapam_xlog.h:192
OffsetNumber offnum
Definition: heapam_xlog.h:274
OffsetNumber offnum
Definition: heapam_xlog.h:253
TransactionId locking_xid
Definition: heapam_xlog.h:252
unsigned char uint8
Definition: c.h:266
#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:191
OffsetNumber offnum
Definition: heapam_xlog.h:105
#define XLogRecGetData(decoder)
Definition: xlogreader.h:220
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:78
TransactionId new_xmax
Definition: heapam_xlog.h:194
int8 infobits_set
Definition: heapam_xlog.h:254
static void out_infobits(StringInfo buf, uint8 infobits)
Definition: heapdesc.c:20
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:216
OffsetNumber offnum
Definition: heapam_xlog.h:282
#define XLR_INFO_MASK
Definition: xlogrecord.h:62
uint8 infobits_set
Definition: heapam_xlog.h:106
#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
OffsetNumber new_offnum
Definition: heapam_xlog.h:195
#define XLOG_HEAP_DELETE
Definition: heapam_xlog.h:33
OffsetNumber offnum
Definition: heapam_xlog.h:132
TransactionId old_xmax
Definition: heapam_xlog.h:190
#define XLOG_HEAP_CONFIRM
Definition: heapam_xlog.h:37
void heap_execute_freeze_tuple ( HeapTupleHeader  tuple,
xl_heap_freeze_tuple xlrec_tp 
)

Definition at line 6748 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().

6749 {
6750  HeapTupleHeaderSetXmax(tuple, frz->xmax);
6751 
6752  if (frz->frzflags & XLH_FREEZE_XVAC)
6754 
6755  if (frz->frzflags & XLH_INVALID_XVAC)
6757 
6758  tuple->t_infomask = frz->t_infomask;
6759  tuple->t_infomask2 = frz->t_infomask2;
6760 }
#define HeapTupleHeaderSetXvac(tup, xid)
Definition: htup_details.h:417
#define HeapTupleHeaderSetXmax(tup, xid)
Definition: htup_details.h:374
#define InvalidTransactionId
Definition: transam.h:31
#define FrozenTransactionId
Definition: transam.h:33
#define XLH_INVALID_XVAC
Definition: heapam_xlog.h:294
#define XLH_FREEZE_XVAC
Definition: heapam_xlog.h:293
const char* heap_identify ( uint8  info)

Definition at line 162 of file heapdesc.c.

References NULL, 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_UPDATE, and XLR_INFO_MASK.

163 {
164  const char *id = NULL;
165 
166  switch (info & ~XLR_INFO_MASK)
167  {
168  case XLOG_HEAP_INSERT:
169  id = "INSERT";
170  break;
172  id = "INSERT+INIT";
173  break;
174  case XLOG_HEAP_DELETE:
175  id = "DELETE";
176  break;
177  case XLOG_HEAP_UPDATE:
178  id = "UPDATE";
179  break;
181  id = "UPDATE+INIT";
182  break;
184  id = "HOT_UPDATE";
185  break;
187  id = "HOT_UPDATE+INIT";
188  break;
189  case XLOG_HEAP_CONFIRM:
190  id = "HEAP_CONFIRM";
191  break;
192  case XLOG_HEAP_LOCK:
193  id = "LOCK";
194  break;
195  case XLOG_HEAP_INPLACE:
196  id = "INPLACE";
197  break;
198  }
199 
200  return id;
201 }
#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 NULL
Definition: c.h:229
#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
void heap_mask ( char *  pagedata,
BlockNumber  blkno 
)

Definition at line 9113 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(), mask_unused_space(), MAXALIGN, PageGetItemId, PageGetMaxOffsetNumber, and HeapTupleHeaderData::t_infomask.

9114 {
9115  Page page = (Page) pagedata;
9116  OffsetNumber off;
9117 
9118  mask_page_lsn(page);
9119 
9120  mask_page_hint_bits(page);
9121  mask_unused_space(page);
9122 
9123  for (off = 1; off <= PageGetMaxOffsetNumber(page); off++)
9124  {
9125  ItemId iid = PageGetItemId(page, off);
9126  char *page_item;
9127 
9128  page_item = (char *) (page + ItemIdGetOffset(iid));
9129 
9130  if (ItemIdIsNormal(iid))
9131  {
9132  HeapTupleHeader page_htup = (HeapTupleHeader) page_item;
9133 
9134  /*
9135  * If xmin of a tuple is not yet frozen, we should ignore
9136  * differences in hint bits, since they can be set without
9137  * emitting WAL.
9138  */
9139  if (!HeapTupleHeaderXminFrozen(page_htup))
9140  page_htup->t_infomask &= ~HEAP_XACT_MASK;
9141  else
9142  {
9143  /* Still we need to mask xmax hint bits. */
9144  page_htup->t_infomask &= ~HEAP_XMAX_INVALID;
9145  page_htup->t_infomask &= ~HEAP_XMAX_COMMITTED;
9146  }
9147 
9148  /*
9149  * During replay, we set Command Id to FirstCommandId. Hence, mask
9150  * it. See heap_xlog_insert() for details.
9151  */
9152  page_htup->t_choice.t_heap.t_field3.t_cid = MASK_MARKER;
9153 
9154  /*
9155  * For a speculative tuple, heap_insert() does not set ctid in the
9156  * caller-passed heap tuple itself, leaving the ctid field to
9157  * contain a speculative token value - a per-backend monotonically
9158  * increasing identifier. Besides, it does not WAL-log ctid under
9159  * any circumstances.
9160  *
9161  * During redo, heap_xlog_insert() sets t_ctid to current block
9162  * number and self offset number. It doesn't care about any
9163  * speculative insertions in master. Hence, we set t_ctid to
9164  * current block number and self offset number to ignore any
9165  * inconsistency.
9166  */
9167  if (HeapTupleHeaderIsSpeculative(page_htup))
9168  ItemPointerSet(&page_htup->t_ctid, blkno, off);
9169  }
9170 
9171  /*
9172  * Ignore any padding bytes after the tuple, when the length of the
9173  * item is not MAXALIGNed.
9174  */
9175  if (ItemIdHasStorage(iid))
9176  {
9177  int len = ItemIdGetLength(iid);
9178  int padlen = MAXALIGN(len) - len;
9179 
9180  if (padlen > 0)
9181  memset(page_item + len, MASK_MARKER, padlen);
9182  }
9183  }
9184 }
union HeapTupleHeaderData::@45 t_choice
HeapTupleFields t_heap
Definition: htup_details.h:146
HeapTupleHeaderData * HeapTupleHeader
Definition: htup.h:23
#define HeapTupleHeaderIsSpeculative(tup)
Definition: htup_details.h:423
void mask_page_hint_bits(Page page)
Definition: bufmask.c:44
#define HEAP_XMAX_COMMITTED
Definition: htup_details.h:192
#define PageGetMaxOffsetNumber(page)
Definition: bufpage.h:353
void mask_unused_space(Page page)
Definition: bufmask.c:69
uint16 OffsetNumber
Definition: off.h:24
#define ItemIdGetLength(itemId)
Definition: itemid.h:58
#define MASK_MARKER
Definition: bufmask.h:24
void mask_page_lsn(Page page)
Definition: bufmask.c:30
#define HEAP_XMAX_INVALID
Definition: htup_details.h:193
ItemPointerData t_ctid
Definition: htup_details.h:150
#define ItemIdGetOffset(itemId)
Definition: itemid.h:64
union HeapTupleFields::@44 t_field3
#define PageGetItemId(page, offsetNumber)
Definition: bufpage.h:231
#define HeapTupleHeaderXminFrozen(tup)
Definition: htup_details.h:329
#define ItemIdHasStorage(itemId)
Definition: itemid.h:119
#define ItemIdIsNormal(itemId)
Definition: itemid.h:98
#define MAXALIGN(LEN)
Definition: c.h:588
#define HEAP_XACT_MASK
Definition: htup_details.h:204
CommandId t_cid
Definition: htup_details.h:123
Pointer Page
Definition: bufpage.h:74
#define ItemPointerSet(pointer, blockNumber, offNum)
Definition: itemptr.h:105
bool heap_prepare_freeze_tuple ( HeapTupleHeader  tuple,
TransactionId  cutoff_xid,
TransactionId  cutoff_multi,
xl_heap_freeze_tuple frz,
bool totally_frozen 
)

Definition at line 6570 of file heapam.c.

References Assert, 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_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, TransactionIdIsNormal, TransactionIdPrecedes(), XLH_FREEZE_XVAC, XLH_INVALID_XVAC, and xl_heap_freeze_tuple::xmax.

Referenced by heap_freeze_tuple(), and lazy_scan_heap().

6573 {
6574  bool changed = false;
6575  bool freeze_xmax = false;
6576  TransactionId xid;
6577  bool totally_frozen = true;
6578 
6579  frz->frzflags = 0;
6580  frz->t_infomask2 = tuple->t_infomask2;
6581  frz->t_infomask = tuple->t_infomask;
6582  frz->xmax = HeapTupleHeaderGetRawXmax(tuple);
6583 
6584  /* Process xmin */
6585  xid = HeapTupleHeaderGetXmin(tuple);
6586  if (TransactionIdIsNormal(xid))
6587  {
6588  if (TransactionIdPrecedes(xid, cutoff_xid))
6589  {
6590  frz->t_infomask |= HEAP_XMIN_FROZEN;
6591  changed = true;
6592  }
6593  else
6594  totally_frozen = false;
6595  }
6596 
6597  /*
6598  * Process xmax. To thoroughly examine the current Xmax value we need to
6599  * resolve a MultiXactId to its member Xids, in case some of them are
6600  * below the given cutoff for Xids. In that case, those values might need
6601  * freezing, too. Also, if a multi needs freezing, we cannot simply take
6602  * it out --- if there's a live updater Xid, it needs to be kept.
6603  *
6604  * Make sure to keep heap_tuple_needs_freeze in sync with this.
6605  */
6606  xid = HeapTupleHeaderGetRawXmax(tuple);
6607 
6608  if (tuple->t_infomask & HEAP_XMAX_IS_MULTI)
6609  {
6610  TransactionId newxmax;
6611  uint16 flags;
6612 
6613  newxmax = FreezeMultiXactId(xid, tuple->t_infomask,
6614  cutoff_xid, cutoff_multi, &flags);
6615 
6616  if (flags & FRM_INVALIDATE_XMAX)
6617  freeze_xmax = true;
6618  else if (flags & FRM_RETURN_IS_XID)
6619  {
6620  /*
6621  * NB -- some of these transformations are only valid because we
6622  * know the return Xid is a tuple updater (i.e. not merely a
6623  * locker.) Also note that the only reason we don't explicitly
6624  * worry about HEAP_KEYS_UPDATED is because it lives in
6625  * t_infomask2 rather than t_infomask.
6626  */
6627  frz->t_infomask &= ~HEAP_XMAX_BITS;
6628  frz->xmax = newxmax;
6629  if (flags & FRM_MARK_COMMITTED)
6631  changed = true;
6632  totally_frozen = false;
6633  }
6634  else if (flags & FRM_RETURN_IS_MULTI)
6635  {
6636  uint16 newbits;
6637  uint16 newbits2;
6638 
6639  /*
6640  * We can't use GetMultiXactIdHintBits directly on the new multi
6641  * here; that routine initializes the masks to all zeroes, which
6642  * would lose other bits we need. Doing it this way ensures all
6643  * unrelated bits remain untouched.
6644  */
6645  frz->t_infomask &= ~HEAP_XMAX_BITS;
6646  frz->t_infomask2 &= ~HEAP_KEYS_UPDATED;
6647  GetMultiXactIdHintBits(newxmax, &newbits, &newbits2);
6648  frz->t_infomask |= newbits;
6649  frz->t_infomask2 |= newbits2;
6650 
6651  frz->xmax = newxmax;
6652 
6653  changed = true;
6654  totally_frozen = false;
6655  }
6656  else
6657  {
6658  Assert(flags & FRM_NOOP);
6659  }
6660  }
6661  else if (TransactionIdIsNormal(xid))
6662  {
6663  if (TransactionIdPrecedes(xid, cutoff_xid))
6664  freeze_xmax = true;
6665  else
6666  totally_frozen = false;
6667  }
6668 
6669  if (freeze_xmax)
6670  {
6671  frz->xmax = InvalidTransactionId;
6672 
6673  /*
6674  * The tuple might be marked either XMAX_INVALID or XMAX_COMMITTED +
6675  * LOCKED. Normalize to INVALID just to be sure no one gets confused.
6676  * Also get rid of the HEAP_KEYS_UPDATED bit.
6677  */
6678  frz->t_infomask &= ~HEAP_XMAX_BITS;
6679  frz->t_infomask |= HEAP_XMAX_INVALID;
6680  frz->t_infomask2 &= ~HEAP_HOT_UPDATED;
6681  frz->t_infomask2 &= ~HEAP_KEYS_UPDATED;
6682  changed = true;
6683  }
6684 
6685  /*
6686  * Old-style VACUUM FULL is gone, but we have to keep this code as long as
6687  * we support having MOVED_OFF/MOVED_IN tuples in the database.
6688  */
6689  if (tuple->t_infomask & HEAP_MOVED)
6690  {
6691  xid = HeapTupleHeaderGetXvac(tuple);
6692 
6693  /*
6694  * For Xvac, we ignore the cutoff_xid and just always perform the
6695  * freeze operation. The oldest release in which such a value can
6696  * actually be set is PostgreSQL 8.4, because old-style VACUUM FULL
6697  * was removed in PostgreSQL 9.0. Note that if we were to respect
6698  * cutoff_xid here, we'd need to make surely to clear totally_frozen
6699  * when we skipped freezing on that basis.
6700  */
6701  if (TransactionIdIsNormal(xid))
6702  {
6703  /*
6704  * If a MOVED_OFF tuple is not dead, the xvac transaction must
6705  * have failed; whereas a non-dead MOVED_IN tuple must mean the
6706  * xvac transaction succeeded.
6707  */
6708  if (tuple->t_infomask & HEAP_MOVED_OFF)
6709  frz->frzflags |= XLH_INVALID_XVAC;
6710  else
6711  frz->frzflags |= XLH_FREEZE_XVAC;
6712 
6713  /*
6714  * Might as well fix the hint bits too; usually XMIN_COMMITTED
6715  * will already be set here, but there's a small chance not.
6716  */
6717  Assert(!(tuple->t_infomask & HEAP_XMIN_INVALID));
6719  changed = true;
6720  }
6721  }
6722 
6723  *totally_frozen_p = totally_frozen;
6724  return changed;
6725 }
#define FRM_RETURN_IS_XID
Definition: heapam.c:6280
static void GetMultiXactIdHintBits(MultiXactId multi, uint16 *new_infomask, uint16 *new_infomask2)
Definition: heapam.c:6797
#define FRM_MARK_COMMITTED
Definition: heapam.c:6282
#define HEAP_XMAX_BITS
Definition: htup_details.h:256
uint32 TransactionId
Definition: c.h:397
static TransactionId FreezeMultiXactId(MultiXactId multi, uint16 t_infomask, TransactionId cutoff_xid, MultiXactId cutoff_multi, uint16 *flags)
Definition: heapam.c:6306
#define HEAP_XMIN_FROZEN
Definition: htup_details.h:191
#define HEAP_XMAX_COMMITTED
Definition: htup_details.h:192
#define HEAP_XMIN_INVALID
Definition: htup_details.h:190
#define HeapTupleHeaderGetRawXmax(tup)
Definition: htup_details.h:369
unsigned short uint16
Definition: c.h:267
#define HEAP_XMAX_INVALID
Definition: htup_details.h:193
#define FRM_INVALIDATE_XMAX
Definition: heapam.c:6279
#define InvalidTransactionId
Definition: transam.h:31
#define HeapTupleHeaderGetXvac(tup)
Definition: htup_details.h:409
bool TransactionIdPrecedes(TransactionId id1, TransactionId id2)
Definition: transam.c:300
#define FRM_RETURN_IS_MULTI
Definition: heapam.c:6281
#define HEAP_KEYS_UPDATED
Definition: htup_details.h:264
#define HEAP_XMAX_IS_MULTI
Definition: htup_details.h:194
#define HEAP_XMIN_COMMITTED
Definition: htup_details.h:189
#define HEAP_MOVED
Definition: htup_details.h:202
#define HEAP_MOVED_OFF
Definition: htup_details.h:196
#define Assert(condition)
Definition: c.h:675
#define FRM_NOOP
Definition: heapam.c:6278
#define HeapTupleHeaderGetXmin(tup)
Definition: htup_details.h:307
TransactionId xmax
Definition: heapam_xlog.h:298
#define HEAP_HOT_UPDATED
Definition: htup_details.h:266
#define XLH_INVALID_XVAC
Definition: heapam_xlog.h:294
#define TransactionIdIsNormal(xid)
Definition: transam.h:42
#define XLH_FREEZE_XVAC
Definition: heapam_xlog.h:293
void heap_redo ( XLogReaderState record)

Definition at line 8992 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_UPDATE, XLogRecGetInfo, and XLR_INFO_MASK.

8993 {
8994  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
8995 
8996  /*
8997  * These operations don't overwrite MVCC data so no conflict processing is
8998  * required. The ones in heap2 rmgr do.
8999  */
9000 
9001  switch (info & XLOG_HEAP_OPMASK)
9002  {
9003  case XLOG_HEAP_INSERT:
9004  heap_xlog_insert(record);
9005  break;
9006  case XLOG_HEAP_DELETE:
9007  heap_xlog_delete(record);
9008  break;
9009  case XLOG_HEAP_UPDATE:
9010  heap_xlog_update(record, false);
9011  break;
9012  case XLOG_HEAP_HOT_UPDATE:
9013  heap_xlog_update(record, true);
9014  break;
9015  case XLOG_HEAP_CONFIRM:
9016  heap_xlog_confirm(record);
9017  break;
9018  case XLOG_HEAP_LOCK:
9019  heap_xlog_lock(record);
9020  break;
9021  case XLOG_HEAP_INPLACE:
9022  heap_xlog_inplace(record);
9023  break;
9024  default:
9025  elog(PANIC, "heap_redo: unknown op code %u", info);
9026  }
9027 }
#define XLOG_HEAP_INSERT
Definition: heapam_xlog.h:32
unsigned char uint8
Definition: c.h:266
#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:8784
static void heap_xlog_lock(XLogReaderState *record)
Definition: heapam.c:8820
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:216
static void heap_xlog_insert(XLogReaderState *record)
Definition: heapam.c:8257
static void heap_xlog_inplace(XLogReaderState *record)
Definition: heapam.c:8951
static void heap_xlog_delete(XLogReaderState *record)
Definition: heapam.c:8187
#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:8512
#define XLOG_HEAP_LOCK
Definition: heapam_xlog.h:38
#define elog
Definition: elog.h:219
#define XLOG_HEAP_DELETE
Definition: heapam_xlog.h:33
#define XLOG_HEAP_CONFIRM
Definition: heapam_xlog.h:37
void heap_xlog_logical_rewrite ( XLogReaderState r)

Definition at line 1118 of file rewriteheap.c.

References CloseTransientFile(), 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(), 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, write, XLogRecGetData, and XLogRecGetXid.

Referenced by heap2_redo().

1119 {
1120  char path[MAXPGPATH];
1121  int fd;
1122  xl_heap_rewrite_mapping *xlrec;
1123  uint32 len;
1124  char *data;
1125 
1126  xlrec = (xl_heap_rewrite_mapping *) XLogRecGetData(r);
1127 
1128  snprintf(path, MAXPGPATH,
1129  "pg_logical/mappings/" LOGICAL_REWRITE_FORMAT,
1130  xlrec->mapped_db, xlrec->mapped_rel,
1131  (uint32) (xlrec->start_lsn >> 32),
1132  (uint32) xlrec->start_lsn,
1133  xlrec->mapped_xid, XLogRecGetXid(r));
1134 
1135  fd = OpenTransientFile(path,
1136  O_CREAT | O_WRONLY | PG_BINARY,
1137  S_IRUSR | S_IWUSR);
1138  if (fd < 0)
1139  ereport(ERROR,
1141  errmsg("could not create file \"%s\": %m", path)));
1142 
1143  /*
1144  * Truncate all data that's not guaranteed to have been safely fsynced (by
1145  * previous record or by the last checkpoint).
1146  */
1148  if (ftruncate(fd, xlrec->offset) != 0)
1149  ereport(ERROR,
1151  errmsg("could not truncate file \"%s\" to %u: %m",
1152  path, (uint32) xlrec->offset)));
1154 
1155  /* now seek to the position we want to write our data to */
1156  if (lseek(fd, xlrec->offset, SEEK_SET) != xlrec->offset)
1157  ereport(ERROR,
1159  errmsg("could not seek to end of file \"%s\": %m",
1160  path)));
1161 
1162  data = XLogRecGetData(r) + sizeof(*xlrec);
1163 
1164  len = xlrec->num_mappings * sizeof(LogicalRewriteMappingData);
1165 
1166  /* write out tail end of mapping file (again) */
1168  if (write(fd, data, len) != len)
1169  ereport(ERROR,
1171  errmsg("could not write to file \"%s\": %m", path)));
1173 
1174  /*
1175  * Now fsync all previously written data. We could improve things and only
1176  * do this for the last write to a file, but the required bookkeeping
1177  * doesn't seem worth the trouble.
1178  */
1180  if (pg_fsync(fd) != 0)
1181  ereport(ERROR,
1183  errmsg("could not fsync file \"%s\": %m", path)));
1185 
1186  CloseTransientFile(fd);
1187 }
#define write(a, b, c)
Definition: win32.h:14
int snprintf(char *str, size_t count, const char *fmt,...) pg_attribute_printf(3
static int fd(const char *x, int i)
Definition: preproc-init.c:105
#define PG_BINARY
Definition: c.h:1038
#define XLogRecGetData(decoder)
Definition: xlogreader.h:220
#define ERROR
Definition: elog.h:43
#define MAXPGPATH
int OpenTransientFile(FileName fileName, int fileFlags, int fileMode)
Definition: fd.c:2144
int errcode_for_file_access(void)
Definition: elog.c:598
unsigned int uint32
Definition: c.h:268
static void pgstat_report_wait_end(void)
Definition: pgstat.h:1232
#define ereport(elevel, rest)
Definition: elog.h:122
int CloseTransientFile(int fd)
Definition: fd.c:2305
#define XLogRecGetXid(decoder)
Definition: xlogreader.h:218
TransactionId mapped_xid
Definition: heapam_xlog.h:362
#define ftruncate(a, b)
Definition: win32.h:59
static void pgstat_report_wait_start(uint32 wait_event_info)
Definition: pgstat.h:1208
#define LOGICAL_REWRITE_FORMAT
Definition: rewriteheap.h:54
int errmsg(const char *fmt,...)
Definition: elog.c:797
struct LogicalRewriteMappingData LogicalRewriteMappingData
int pg_fsync(int fd)
Definition: fd.c:333
void HeapTupleHeaderAdvanceLatestRemovedXid ( HeapTupleHeader  tuple,
TransactionId latestRemovedXid 
)

Definition at line 7280 of file heapam.c.

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

Referenced by btree_xlog_delete_get_latestRemovedXid(), hash_xlog_vacuum_get_latestRemovedXid(), heap_prune_chain(), and lazy_scan_heap().

7282 {
7283  TransactionId xmin = HeapTupleHeaderGetXmin(tuple);
7285  TransactionId xvac = HeapTupleHeaderGetXvac(tuple);
7286 
7287  if (tuple->t_infomask & HEAP_MOVED)
7288  {
7289  if (TransactionIdPrecedes(*latestRemovedXid, xvac))
7290  *latestRemovedXid = xvac;
7291  }
7292 
7293  /*
7294  * Ignore tuples inserted by an aborted transaction or if the tuple was
7295  * updated/deleted by the inserting transaction.
7296  *
7297  * Look for a committed hint bit, or if no xmin bit is set, check clog.
7298  * This needs to work on both master and standby, where it is used to
7299  * assess btree delete records.
7300  */
7301  if (HeapTupleHeaderXminCommitted(tuple) ||
7303  {
7304  if (xmax != xmin &&
7305  TransactionIdFollows(xmax, *latestRemovedXid))
7306  *latestRemovedXid = xmax;
7307  }
7308 
7309  /* *latestRemovedXid may still be invalid at end */
7310 }
#define HeapTupleHeaderGetUpdateXid(tup)
Definition: htup_details.h:359
bool TransactionIdFollows(TransactionId id1, TransactionId id2)
Definition: transam.c:334
uint32 TransactionId
Definition: c.h:397
#define HeapTupleHeaderXminInvalid(tup)
Definition: htup_details.h:323
bool TransactionIdDidCommit(TransactionId transactionId)
Definition: transam.c:125
#define HeapTupleHeaderXminCommitted(tup)
Definition: htup_details.h:318
#define HeapTupleHeaderGetXvac(tup)
Definition: htup_details.h:409
bool TransactionIdPrecedes(TransactionId id1, TransactionId id2)
Definition: transam.c:300
#define HEAP_MOVED
Definition: htup_details.h:202
#define HeapTupleHeaderGetXmin(tup)
Definition: htup_details.h:307
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 7348 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().

7353 {
7354  xl_heap_clean xlrec;
7355  XLogRecPtr recptr;
7356 
7357  /* Caller should not call me on a non-WAL-logged relation */
7358  Assert(RelationNeedsWAL(reln));
7359 
7360  xlrec.latestRemovedXid = latestRemovedXid;
7361  xlrec.nredirected = nredirected;
7362  xlrec.ndead = ndead;
7363 
7364  XLogBeginInsert();
7365  XLogRegisterData((char *) &xlrec, SizeOfHeapClean);
7366 
7368 
7369  /*
7370  * The OffsetNumber arrays are not actually in the buffer, but we pretend
7371  * that they are. When XLogInsert stores the whole buffer, the offset
7372  * arrays need not be stored too. Note that even if all three arrays are
7373  * empty, we want to expose the buffer as a candidate for whole-page
7374  * storage, since this record type implies a defragmentation operation
7375  * even if no item pointers changed state.
7376  */
7377  if (nredirected > 0)
7378  XLogRegisterBufData(0, (char *) redirected,
7379  nredirected * sizeof(OffsetNumber) * 2);
7380 
7381  if (ndead > 0)
7382  XLogRegisterBufData(0, (char *) nowdead,
7383  ndead * sizeof(OffsetNumber));
7384 
7385  if (nunused > 0)
7386  XLogRegisterBufData(0, (char *) nowunused,
7387  nunused * sizeof(OffsetNumber));
7388 
7389  recptr = XLogInsert(RM_HEAP2_ID, XLOG_HEAP2_CLEAN);
7390 
7391  return recptr;
7392 }
void XLogRegisterBufData(uint8 block_id, char *data, int len)
Definition: xloginsert.c:361
uint16 nredirected
Definition: heapam_xlog.h:219
void XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags)
Definition: xloginsert.c:213
uint16 OffsetNumber
Definition: off.h:24
#define SizeOfHeapClean
Definition: heapam_xlog.h:224
#define XLOG_HEAP2_CLEAN
Definition: heapam_xlog.h:54
#define REGBUF_STANDARD
Definition: xloginsert.h:34
void XLogRegisterData(char *data, int len)
Definition: xloginsert.c:323
XLogRecPtr XLogInsert(RmgrId rmid, uint8 info)
Definition: xloginsert.c:415
uint64 XLogRecPtr
Definition: xlogdefs.h:21
#define Assert(condition)
Definition: c.h:675
WalTimeSample buffer[LAG_TRACKER_BUFFER_SIZE]
Definition: walsender.c:214
#define RelationNeedsWAL(relation)
Definition: rel.h:505
TransactionId latestRemovedXid
Definition: heapam_xlog.h:218
void XLogBeginInsert(void)
Definition: xloginsert.c:120
XLogRecPtr log_heap_cleanup_info ( RelFileNode  rnode,
TransactionId  latestRemovedXid 
)

Definition at line 7319 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().

7320 {
7321  xl_heap_cleanup_info xlrec;
7322  XLogRecPtr recptr;
7323 
7324  xlrec.node = rnode;
7325  xlrec.latestRemovedXid = latestRemovedXid;
7326 
7327  XLogBeginInsert();
7328  XLogRegisterData((char *) &xlrec, SizeOfHeapCleanupInfo);
7329 
7330  recptr = XLogInsert(RM_HEAP2_ID, XLOG_HEAP2_CLEANUP_INFO);
7331 
7332  return recptr;
7333 }
#define SizeOfHeapCleanupInfo
Definition: heapam_xlog.h:237
#define XLOG_HEAP2_CLEANUP_INFO
Definition: heapam_xlog.h:56
void XLogRegisterData(char *data, int len)
Definition: xloginsert.c:323
XLogRecPtr XLogInsert(RmgrId rmid, uint8 info)
Definition: xloginsert.c:415
uint64 XLogRecPtr
Definition: xlogdefs.h:21
void XLogBeginInsert(void)
Definition: xloginsert.c:120
TransactionId latestRemovedXid
Definition: heapam_xlog.h:234
XLogRecPtr log_heap_freeze ( Relation  reln,
Buffer  buffer,
TransactionId  cutoff_xid,
xl_heap_freeze_tuple tuples,
int  ntuples 
)

Definition at line 7399 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().

7401 {
7402  xl_heap_freeze_page xlrec;
7403  XLogRecPtr recptr;
7404 
7405  /* Caller should not call me on a non-WAL-logged relation */
7406  Assert(RelationNeedsWAL(reln));
7407  /* nor when there are no tuples to freeze */
7408  Assert(ntuples > 0);
7409 
7410  xlrec.cutoff_xid = cutoff_xid;
7411  xlrec.ntuples = ntuples;
7412 
7413  XLogBeginInsert();
7414  XLogRegisterData((char *) &xlrec, SizeOfHeapFreezePage);
7415 
7416  /*
7417  * The freeze plan array is not actually in the buffer, but pretend that
7418  * it is. When XLogInsert stores the whole buffer, the freeze plan need
7419  * not be stored too.
7420  */
7422  XLogRegisterBufData(0, (char *) tuples,
7423  ntuples * sizeof(xl_heap_freeze_tuple));
7424 
7425  recptr = XLogInsert(RM_HEAP2_ID, XLOG_HEAP2_FREEZE_PAGE);
7426 
7427  return recptr;
7428 }
void XLogRegisterBufData(uint8 block_id, char *data, int len)
Definition: xloginsert.c:361
void XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags)
Definition: xloginsert.c:213
TransactionId cutoff_xid
Definition: heapam_xlog.h:313
#define SizeOfHeapFreezePage
Definition: heapam_xlog.h:317
#define REGBUF_STANDARD
Definition: xloginsert.h:34
void XLogRegisterData(char *data, int len)
Definition: xloginsert.c:323
XLogRecPtr XLogInsert(RmgrId rmid, uint8 info)
Definition: xloginsert.c:415
uint64 XLogRecPtr
Definition: xlogdefs.h:21
#define Assert(condition)
Definition: c.h:675
WalTimeSample buffer[LAG_TRACKER_BUFFER_SIZE]
Definition: walsender.c:214
#define RelationNeedsWAL(relation)
Definition: rel.h:505
#define XLOG_HEAP2_FREEZE_PAGE
Definition: heapam_xlog.h:55
void XLogBeginInsert(void)
Definition: xloginsert.c:120
XLogRecPtr log_heap_visible ( RelFileNode  rnode,
Buffer  heap_buffer,
Buffer  vm_buffer,
TransactionId  cutoff_xid,
uint8  flags 
)

Definition at line 7440 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().

7442 {
7443  xl_heap_visible xlrec;
7444  XLogRecPtr recptr;
7445  uint8 flags;
7446 
7447  Assert(BufferIsValid(heap_buffer));
7448  Assert(BufferIsValid(vm_buffer));
7449 
7450  xlrec.cutoff_xid = cutoff_xid;
7451  xlrec.flags = vmflags;
7452  XLogBeginInsert();
7453  XLogRegisterData((char *) &xlrec, SizeOfHeapVisible);
7454 
7455  XLogRegisterBuffer(0, vm_buffer, 0);
7456 
7457  flags = REGBUF_STANDARD;
7458  if (!XLogHintBitIsNeeded())
7459  flags |= REGBUF_NO_IMAGE;
7460  XLogRegisterBuffer(1, heap_buffer, flags);
7461 
7462  recptr = XLogInsert(RM_HEAP2_ID, XLOG_HEAP2_VISIBLE);
7463 
7464  return recptr;
7465 }
void XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags)
Definition: xloginsert.c:213
unsigned char uint8
Definition: c.h:266
#define XLOG_HEAP2_VISIBLE
Definition: heapam_xlog.h:57
TransactionId cutoff_xid
Definition: heapam_xlog.h:327
#define REGBUF_STANDARD
Definition: xloginsert.h:34
void XLogRegisterData(char *data, int len)
Definition: xloginsert.c:323
XLogRecPtr XLogInsert(RmgrId rmid, uint8 info)
Definition: xloginsert.c:415
#define SizeOfHeapVisible
Definition: heapam_xlog.h:331
uint64 XLogRecPtr
Definition: xlogdefs.h:21
#define Assert(condition)
Definition: c.h:675
#define REGBUF_NO_IMAGE
Definition: xloginsert.h:31
#define BufferIsValid(bufnum)
Definition: bufmgr.h:114
void XLogBeginInsert(void)
Definition: xloginsert.c:120
#define XLogHintBitIsNeeded()
Definition: xlog.h:156