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/relfilelocator.h"
#include "utils/relcache.h"
Include dependency graph for heapam_xlog.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

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

Macros

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

Typedefs

typedef struct xl_heap_delete xl_heap_delete
 
typedef struct xl_heap_truncate xl_heap_truncate
 
typedef struct xl_heap_header xl_heap_header
 
typedef struct xl_heap_insert xl_heap_insert
 
typedef struct xl_heap_multi_insert xl_heap_multi_insert
 
typedef struct xl_multi_insert_tuple xl_multi_insert_tuple
 
typedef struct xl_heap_update xl_heap_update
 
typedef struct xl_heap_prune xl_heap_prune
 
typedef struct xl_heap_vacuum xl_heap_vacuum
 
typedef struct xl_heap_lock xl_heap_lock
 
typedef struct xl_heap_lock_updated xl_heap_lock_updated
 
typedef struct xl_heap_confirm xl_heap_confirm
 
typedef struct xl_heap_inplace xl_heap_inplace
 
typedef struct xl_heap_freeze_plan xl_heap_freeze_plan
 
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 HeapTupleHeaderAdvanceConflictHorizon (HeapTupleHeader tuple, TransactionId *snapshotConflictHorizon)
 
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_visible (RelFileLocator rlocator, Buffer heap_buffer, Buffer vm_buffer, TransactionId snapshotConflictHorizon, uint8 vmflags)
 

Macro Definition Documentation

◆ SizeOfHeapConfirm

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

Definition at line 305 of file heapam_xlog.h.

◆ SizeOfHeapDelete

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

Definition at line 115 of file heapam_xlog.h.

◆ SizeOfHeapFreezePage

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

Definition at line 352 of file heapam_xlog.h.

◆ SizeOfHeapHeader

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

Definition at line 151 of file heapam_xlog.h.

◆ SizeOfHeapInplace

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

Definition at line 314 of file heapam_xlog.h.

◆ SizeOfHeapInsert

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

Definition at line 162 of file heapam_xlog.h.

◆ SizeOfHeapLock

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

Definition at line 286 of file heapam_xlog.h.

◆ SizeOfHeapLockUpdated

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

Definition at line 297 of file heapam_xlog.h.

◆ SizeOfHeapMultiInsert

#define SizeOfHeapMultiInsert   offsetof(xl_heap_multi_insert, offsets)

Definition at line 182 of file heapam_xlog.h.

◆ SizeOfHeapNewCid

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

Definition at line 386 of file heapam_xlog.h.

◆ SizeOfHeapPrune

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

Definition at line 251 of file heapam_xlog.h.

◆ SizeOfHeapTruncate

#define SizeOfHeapTruncate   (offsetof(xl_heap_truncate, relids))

Definition at line 136 of file heapam_xlog.h.

◆ SizeOfHeapUpdate

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

Definition at line 227 of file heapam_xlog.h.

◆ SizeOfHeapVacuum

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

Definition at line 265 of file heapam_xlog.h.

◆ SizeOfHeapVisible

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

Definition at line 366 of file heapam_xlog.h.

◆ SizeOfMultiInsertTuple

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

Definition at line 193 of file heapam_xlog.h.

◆ XLH_DELETE_ALL_VISIBLE_CLEARED

#define XLH_DELETE_ALL_VISIBLE_CLEARED   (1<<0)

Definition at line 96 of file heapam_xlog.h.

◆ XLH_DELETE_CONTAINS_OLD

#define XLH_DELETE_CONTAINS_OLD    (XLH_DELETE_CONTAINS_OLD_TUPLE | XLH_DELETE_CONTAINS_OLD_KEY)

Definition at line 103 of file heapam_xlog.h.

◆ XLH_DELETE_CONTAINS_OLD_KEY

#define XLH_DELETE_CONTAINS_OLD_KEY   (1<<2)

Definition at line 98 of file heapam_xlog.h.

◆ XLH_DELETE_CONTAINS_OLD_TUPLE

#define XLH_DELETE_CONTAINS_OLD_TUPLE   (1<<1)

Definition at line 97 of file heapam_xlog.h.

◆ XLH_DELETE_IS_PARTITION_MOVE

#define XLH_DELETE_IS_PARTITION_MOVE   (1<<4)

Definition at line 100 of file heapam_xlog.h.

◆ XLH_DELETE_IS_SUPER

#define XLH_DELETE_IS_SUPER   (1<<3)

Definition at line 99 of file heapam_xlog.h.

◆ XLH_FREEZE_XVAC

#define XLH_FREEZE_XVAC   0x02

Definition at line 321 of file heapam_xlog.h.

◆ XLH_INSERT_ALL_FROZEN_SET

#define XLH_INSERT_ALL_FROZEN_SET   (1<<5)

Definition at line 73 of file heapam_xlog.h.

◆ XLH_INSERT_ALL_VISIBLE_CLEARED

#define XLH_INSERT_ALL_VISIBLE_CLEARED   (1<<0)

Definition at line 66 of file heapam_xlog.h.

◆ XLH_INSERT_CONTAINS_NEW_TUPLE

#define XLH_INSERT_CONTAINS_NEW_TUPLE   (1<<3)

Definition at line 69 of file heapam_xlog.h.

◆ XLH_INSERT_IS_SPECULATIVE

#define XLH_INSERT_IS_SPECULATIVE   (1<<2)

Definition at line 68 of file heapam_xlog.h.

◆ XLH_INSERT_LAST_IN_MULTI

#define XLH_INSERT_LAST_IN_MULTI   (1<<1)

Definition at line 67 of file heapam_xlog.h.

◆ XLH_INSERT_ON_TOAST_RELATION

#define XLH_INSERT_ON_TOAST_RELATION   (1<<4)

Definition at line 70 of file heapam_xlog.h.

◆ XLH_INVALID_XVAC

#define XLH_INVALID_XVAC   0x04

Definition at line 322 of file heapam_xlog.h.

◆ XLH_LOCK_ALL_FROZEN_CLEARED

#define XLH_LOCK_ALL_FROZEN_CLEARED   0x01

Definition at line 275 of file heapam_xlog.h.

◆ XLH_TRUNCATE_CASCADE

#define XLH_TRUNCATE_CASCADE   (1<<0)

Definition at line 120 of file heapam_xlog.h.

◆ XLH_TRUNCATE_RESTART_SEQS

#define XLH_TRUNCATE_RESTART_SEQS   (1<<1)

Definition at line 121 of file heapam_xlog.h.

◆ XLH_UPDATE_CONTAINS_NEW_TUPLE

#define XLH_UPDATE_CONTAINS_NEW_TUPLE   (1<<4)

Definition at line 84 of file heapam_xlog.h.

◆ XLH_UPDATE_CONTAINS_OLD

#define XLH_UPDATE_CONTAINS_OLD    (XLH_UPDATE_CONTAINS_OLD_TUPLE | XLH_UPDATE_CONTAINS_OLD_KEY)

Definition at line 89 of file heapam_xlog.h.

◆ XLH_UPDATE_CONTAINS_OLD_KEY

#define XLH_UPDATE_CONTAINS_OLD_KEY   (1<<3)

Definition at line 83 of file heapam_xlog.h.

◆ XLH_UPDATE_CONTAINS_OLD_TUPLE

#define XLH_UPDATE_CONTAINS_OLD_TUPLE   (1<<2)

Definition at line 82 of file heapam_xlog.h.

◆ XLH_UPDATE_NEW_ALL_VISIBLE_CLEARED

#define XLH_UPDATE_NEW_ALL_VISIBLE_CLEARED   (1<<1)

Definition at line 81 of file heapam_xlog.h.

◆ XLH_UPDATE_OLD_ALL_VISIBLE_CLEARED

#define XLH_UPDATE_OLD_ALL_VISIBLE_CLEARED   (1<<0)

Definition at line 79 of file heapam_xlog.h.

◆ XLH_UPDATE_PREFIX_FROM_OLD

#define XLH_UPDATE_PREFIX_FROM_OLD   (1<<5)

Definition at line 85 of file heapam_xlog.h.

◆ XLH_UPDATE_SUFFIX_FROM_OLD

#define XLH_UPDATE_SUFFIX_FROM_OLD   (1<<6)

Definition at line 86 of file heapam_xlog.h.

◆ XLHL_KEYS_UPDATED

#define XLHL_KEYS_UPDATED   0x10

Definition at line 272 of file heapam_xlog.h.

◆ XLHL_XMAX_EXCL_LOCK

#define XLHL_XMAX_EXCL_LOCK   0x04

Definition at line 270 of file heapam_xlog.h.

◆ XLHL_XMAX_IS_MULTI

#define XLHL_XMAX_IS_MULTI   0x01

Definition at line 268 of file heapam_xlog.h.

◆ XLHL_XMAX_KEYSHR_LOCK

#define XLHL_XMAX_KEYSHR_LOCK   0x08

Definition at line 271 of file heapam_xlog.h.

◆ XLHL_XMAX_LOCK_ONLY

#define XLHL_XMAX_LOCK_ONLY   0x02

Definition at line 269 of file heapam_xlog.h.

◆ XLOG_HEAP2_FREEZE_PAGE

#define XLOG_HEAP2_FREEZE_PAGE   0x30

Definition at line 56 of file heapam_xlog.h.

◆ XLOG_HEAP2_LOCK_UPDATED

#define XLOG_HEAP2_LOCK_UPDATED   0x60

Definition at line 59 of file heapam_xlog.h.

◆ XLOG_HEAP2_MULTI_INSERT

#define XLOG_HEAP2_MULTI_INSERT   0x50

Definition at line 58 of file heapam_xlog.h.

◆ XLOG_HEAP2_NEW_CID

#define XLOG_HEAP2_NEW_CID   0x70

Definition at line 60 of file heapam_xlog.h.

◆ XLOG_HEAP2_PRUNE

#define XLOG_HEAP2_PRUNE   0x10

Definition at line 54 of file heapam_xlog.h.

◆ XLOG_HEAP2_REWRITE

#define XLOG_HEAP2_REWRITE   0x00

Definition at line 53 of file heapam_xlog.h.

◆ XLOG_HEAP2_VACUUM

#define XLOG_HEAP2_VACUUM   0x20

Definition at line 55 of file heapam_xlog.h.

◆ XLOG_HEAP2_VISIBLE

#define XLOG_HEAP2_VISIBLE   0x40

Definition at line 57 of file heapam_xlog.h.

◆ XLOG_HEAP_CONFIRM

#define XLOG_HEAP_CONFIRM   0x50

Definition at line 37 of file heapam_xlog.h.

◆ XLOG_HEAP_DELETE

#define XLOG_HEAP_DELETE   0x10

Definition at line 33 of file heapam_xlog.h.

◆ XLOG_HEAP_HOT_UPDATE

#define XLOG_HEAP_HOT_UPDATE   0x40

Definition at line 36 of file heapam_xlog.h.

◆ XLOG_HEAP_INIT_PAGE

#define XLOG_HEAP_INIT_PAGE   0x80

Definition at line 46 of file heapam_xlog.h.

◆ XLOG_HEAP_INPLACE

#define XLOG_HEAP_INPLACE   0x70

Definition at line 39 of file heapam_xlog.h.

◆ XLOG_HEAP_INSERT

#define XLOG_HEAP_INSERT   0x00

Definition at line 32 of file heapam_xlog.h.

◆ XLOG_HEAP_LOCK

#define XLOG_HEAP_LOCK   0x60

Definition at line 38 of file heapam_xlog.h.

◆ XLOG_HEAP_OPMASK

#define XLOG_HEAP_OPMASK   0x70

Definition at line 41 of file heapam_xlog.h.

◆ XLOG_HEAP_TRUNCATE

#define XLOG_HEAP_TRUNCATE   0x30

Definition at line 35 of file heapam_xlog.h.

◆ XLOG_HEAP_UPDATE

#define XLOG_HEAP_UPDATE   0x20

Definition at line 34 of file heapam_xlog.h.

Typedef Documentation

◆ xl_heap_confirm

◆ xl_heap_delete

◆ xl_heap_freeze_page

◆ xl_heap_freeze_plan

◆ xl_heap_header

◆ xl_heap_inplace

◆ xl_heap_insert

◆ xl_heap_lock

typedef struct xl_heap_lock xl_heap_lock

◆ xl_heap_lock_updated

◆ xl_heap_multi_insert

◆ xl_heap_new_cid

◆ xl_heap_prune

typedef struct xl_heap_prune xl_heap_prune

◆ xl_heap_rewrite_mapping

◆ xl_heap_truncate

◆ xl_heap_update

◆ xl_heap_vacuum

◆ xl_heap_visible

◆ xl_multi_insert_tuple

Function Documentation

◆ heap2_desc()

void heap2_desc ( StringInfo  buf,
XLogReaderState record 
)

Definition at line 118 of file heapdesc.c.

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

References appendStringInfo(), buf, xl_heap_new_cid::cmax, xl_heap_new_cid::cmin, xl_heap_new_cid::combocid, RelFileLocator::dbOid, xl_heap_multi_insert::flags, xl_heap_lock_updated::flags, xl_heap_visible::flags, xl_heap_lock_updated::infobits_set, ItemPointerGetBlockNumber(), ItemPointerGetOffsetNumber(), xl_heap_prune::ndead, xl_heap_freeze_page::nplans, xl_heap_prune::nredirected, xl_heap_multi_insert::ntuples, xl_heap_vacuum::nunused, xl_heap_lock_updated::offnum, out_infobits(), RelFileLocator::relNumber, xl_heap_prune::snapshotConflictHorizon, xl_heap_freeze_page::snapshotConflictHorizon, xl_heap_visible::snapshotConflictHorizon, RelFileLocator::spcOid, xl_heap_new_cid::target_locator, xl_heap_new_cid::target_tid, XLOG_HEAP2_FREEZE_PAGE, XLOG_HEAP2_LOCK_UPDATED, XLOG_HEAP2_MULTI_INSERT, XLOG_HEAP2_NEW_CID, XLOG_HEAP2_PRUNE, XLOG_HEAP2_VACUUM, XLOG_HEAP2_VISIBLE, XLOG_HEAP_OPMASK, XLogRecGetData, XLogRecGetInfo, XLR_INFO_MASK, and xl_heap_lock_updated::xmax.

◆ heap2_identify()

const char* heap2_identify ( uint8  info)

Definition at line 229 of file heapdesc.c.

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

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

◆ heap2_redo()

void heap2_redo ( XLogReaderState record)

Definition at line 10064 of file heapam.c.

10065 {
10066  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
10067 
10068  switch (info & XLOG_HEAP_OPMASK)
10069  {
10070  case XLOG_HEAP2_PRUNE:
10071  heap_xlog_prune(record);
10072  break;
10073  case XLOG_HEAP2_VACUUM:
10074  heap_xlog_vacuum(record);
10075  break;
10077  heap_xlog_freeze_page(record);
10078  break;
10079  case XLOG_HEAP2_VISIBLE:
10080  heap_xlog_visible(record);
10081  break;
10083  heap_xlog_multi_insert(record);
10084  break;
10086  heap_xlog_lock_updated(record);
10087  break;
10088  case XLOG_HEAP2_NEW_CID:
10089 
10090  /*
10091  * Nothing to do on a real replay, only used during logical
10092  * decoding.
10093  */
10094  break;
10095  case XLOG_HEAP2_REWRITE:
10096  heap_xlog_logical_rewrite(record);
10097  break;
10098  default:
10099  elog(PANIC, "heap2_redo: unknown op code %u", info);
10100  }
10101 }
#define PANIC
Definition: elog.h:42
static void heap_xlog_prune(XLogReaderState *record)
Definition: heapam.c:8680
static void heap_xlog_vacuum(XLogReaderState *record)
Definition: heapam.c:8767
static void heap_xlog_lock_updated(XLogReaderState *record)
Definition: heapam.c:9917
static void heap_xlog_multi_insert(XLogReaderState *record)
Definition: heapam.c:9391
static void heap_xlog_visible(XLogReaderState *record)
Definition: heapam.c:8842
static void heap_xlog_freeze_page(XLogReaderState *record)
Definition: heapam.c:9105
void heap_xlog_logical_rewrite(XLogReaderState *r)
Definition: rewriteheap.c:1107

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

◆ heap_desc()

void heap_desc ( StringInfo  buf,
XLogReaderState record 
)

Definition at line 35 of file heapdesc.c.

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

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

◆ heap_identify()

const char* heap_identify ( uint8  info)

Definition at line 184 of file heapdesc.c.

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

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

◆ heap_mask()

void heap_mask ( char *  pagedata,
BlockNumber  blkno 
)

Definition at line 10107 of file heapam.c.

10108 {
10109  Page page = (Page) pagedata;
10110  OffsetNumber off;
10111 
10113 
10114  mask_page_hint_bits(page);
10115  mask_unused_space(page);
10116 
10117  for (off = 1; off <= PageGetMaxOffsetNumber(page); off++)
10118  {
10119  ItemId iid = PageGetItemId(page, off);
10120  char *page_item;
10121 
10122  page_item = (char *) (page + ItemIdGetOffset(iid));
10123 
10124  if (ItemIdIsNormal(iid))
10125  {
10126  HeapTupleHeader page_htup = (HeapTupleHeader) page_item;
10127 
10128  /*
10129  * If xmin of a tuple is not yet frozen, we should ignore
10130  * differences in hint bits, since they can be set without
10131  * emitting WAL.
10132  */
10133  if (!HeapTupleHeaderXminFrozen(page_htup))
10134  page_htup->t_infomask &= ~HEAP_XACT_MASK;
10135  else
10136  {
10137  /* Still we need to mask xmax hint bits. */
10138  page_htup->t_infomask &= ~HEAP_XMAX_INVALID;
10139  page_htup->t_infomask &= ~HEAP_XMAX_COMMITTED;
10140  }
10141 
10142  /*
10143  * During replay, we set Command Id to FirstCommandId. Hence, mask
10144  * it. See heap_xlog_insert() for details.
10145  */
10146  page_htup->t_choice.t_heap.t_field3.t_cid = MASK_MARKER;
10147 
10148  /*
10149  * For a speculative tuple, heap_insert() does not set ctid in the
10150  * caller-passed heap tuple itself, leaving the ctid field to
10151  * contain a speculative token value - a per-backend monotonically
10152  * increasing identifier. Besides, it does not WAL-log ctid under
10153  * any circumstances.
10154  *
10155  * During redo, heap_xlog_insert() sets t_ctid to current block
10156  * number and self offset number. It doesn't care about any
10157  * speculative insertions on the primary. Hence, we set t_ctid to
10158  * current block number and self offset number to ignore any
10159  * inconsistency.
10160  */
10161  if (HeapTupleHeaderIsSpeculative(page_htup))
10162  ItemPointerSet(&page_htup->t_ctid, blkno, off);
10163 
10164  /*
10165  * NB: Not ignoring ctid changes due to the tuple having moved
10166  * (i.e. HeapTupleHeaderIndicatesMovedPartitions), because that's
10167  * important information that needs to be in-sync between primary
10168  * and standby, and thus is WAL logged.
10169  */
10170  }
10171 
10172  /*
10173  * Ignore any padding bytes after the tuple, when the length of the
10174  * item is not MAXALIGNed.
10175  */
10176  if (ItemIdHasStorage(iid))
10177  {
10178  int len = ItemIdGetLength(iid);
10179  int padlen = MAXALIGN(len) - len;
10180 
10181  if (padlen > 0)
10182  memset(page_item + len, MASK_MARKER, padlen);
10183  }
10184  }
10185 }
void mask_page_lsn_and_checksum(Page page)
Definition: bufmask.c:31
void mask_unused_space(Page page)
Definition: bufmask.c:71
void mask_page_hint_bits(Page page)
Definition: bufmask.c:46
#define MASK_MARKER
Definition: bufmask.h:24
Pointer Page
Definition: bufpage.h:78
static ItemId PageGetItemId(Page page, OffsetNumber offsetNumber)
Definition: bufpage.h:240
static OffsetNumber PageGetMaxOffsetNumber(Page page)
Definition: bufpage.h:369
#define MAXALIGN(LEN)
Definition: c.h:747
HeapTupleHeaderData * HeapTupleHeader
Definition: htup.h:23
#define HEAP_XMAX_COMMITTED
Definition: htup_details.h:206
#define HEAP_XACT_MASK
Definition: htup_details.h:214
#define HeapTupleHeaderXminFrozen(tup)
Definition: htup_details.h:330
#define HEAP_XMAX_INVALID
Definition: htup_details.h:207
#define HeapTupleHeaderIsSpeculative(tup)
Definition: htup_details.h:424
#define ItemIdGetLength(itemId)
Definition: itemid.h:59
#define ItemIdIsNormal(itemId)
Definition: itemid.h:99
#define ItemIdGetOffset(itemId)
Definition: itemid.h:65
#define ItemIdHasStorage(itemId)
Definition: itemid.h:120
static void ItemPointerSet(ItemPointerData *pointer, BlockNumber blockNumber, OffsetNumber offNum)
Definition: itemptr.h:135
uint16 OffsetNumber
Definition: off.h:24
const void size_t len
CommandId t_cid
Definition: htup_details.h:128
union HeapTupleFields::@43 t_field3
union HeapTupleHeaderData::@44 t_choice
ItemPointerData t_ctid
Definition: htup_details.h:160
HeapTupleFields t_heap
Definition: htup_details.h:156

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

◆ heap_redo()

void heap_redo ( XLogReaderState record)

Definition at line 10018 of file heapam.c.

10019 {
10020  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
10021 
10022  /*
10023  * These operations don't overwrite MVCC data so no conflict processing is
10024  * required. The ones in heap2 rmgr do.
10025  */
10026 
10027  switch (info & XLOG_HEAP_OPMASK)
10028  {
10029  case XLOG_HEAP_INSERT:
10030  heap_xlog_insert(record);
10031  break;
10032  case XLOG_HEAP_DELETE:
10033  heap_xlog_delete(record);
10034  break;
10035  case XLOG_HEAP_UPDATE:
10036  heap_xlog_update(record, false);
10037  break;
10038  case XLOG_HEAP_TRUNCATE:
10039 
10040  /*
10041  * TRUNCATE is a no-op because the actions are already logged as
10042  * SMGR WAL records. TRUNCATE WAL record only exists for logical
10043  * decoding.
10044  */
10045  break;
10046  case XLOG_HEAP_HOT_UPDATE:
10047  heap_xlog_update(record, true);
10048  break;
10049  case XLOG_HEAP_CONFIRM:
10050  heap_xlog_confirm(record);
10051  break;
10052  case XLOG_HEAP_LOCK:
10053  heap_xlog_lock(record);
10054  break;
10055  case XLOG_HEAP_INPLACE:
10056  heap_xlog_inplace(record);
10057  break;
10058  default:
10059  elog(PANIC, "heap_redo: unknown op code %u", info);
10060  }
10061 }
static void heap_xlog_insert(XLogReaderState *record)
Definition: heapam.c:9271
static void heap_xlog_update(XLogReaderState *record, bool hot_update)
Definition: heapam.c:9538
static void heap_xlog_delete(XLogReaderState *record)
Definition: heapam.c:9198
static void heap_xlog_lock(XLogReaderState *record)
Definition: heapam.c:9846
static void heap_xlog_inplace(XLogReaderState *record)
Definition: heapam.c:9977
static void heap_xlog_confirm(XLogReaderState *record)
Definition: heapam.c:9810

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

◆ heap_xlog_logical_rewrite()

void heap_xlog_logical_rewrite ( XLogReaderState r)

Definition at line 1107 of file rewriteheap.c.

1108 {
1109  char path[MAXPGPATH];
1110  int fd;
1111  xl_heap_rewrite_mapping *xlrec;
1112  uint32 len;
1113  char *data;
1114 
1115  xlrec = (xl_heap_rewrite_mapping *) XLogRecGetData(r);
1116 
1117  snprintf(path, MAXPGPATH,
1118  "pg_logical/mappings/" LOGICAL_REWRITE_FORMAT,
1119  xlrec->mapped_db, xlrec->mapped_rel,
1120  LSN_FORMAT_ARGS(xlrec->start_lsn),
1121  xlrec->mapped_xid, XLogRecGetXid(r));
1122 
1123  fd = OpenTransientFile(path,
1124  O_CREAT | O_WRONLY | PG_BINARY);
1125  if (fd < 0)
1126  ereport(ERROR,
1128  errmsg("could not create file \"%s\": %m", path)));
1129 
1130  /*
1131  * Truncate all data that's not guaranteed to have been safely fsynced (by
1132  * previous record or by the last checkpoint).
1133  */
1135  if (ftruncate(fd, xlrec->offset) != 0)
1136  ereport(ERROR,
1138  errmsg("could not truncate file \"%s\" to %u: %m",
1139  path, (uint32) xlrec->offset)));
1141 
1142  data = XLogRecGetData(r) + sizeof(*xlrec);
1143 
1144  len = xlrec->num_mappings * sizeof(LogicalRewriteMappingData);
1145 
1146  /* write out tail end of mapping file (again) */
1147  errno = 0;
1149  if (pg_pwrite(fd, data, len, xlrec->offset) != len)
1150  {
1151  /* if write didn't set errno, assume problem is no disk space */
1152  if (errno == 0)
1153  errno = ENOSPC;
1154  ereport(ERROR,
1156  errmsg("could not write to file \"%s\": %m", path)));
1157  }
1159 
1160  /*
1161  * Now fsync all previously written data. We could improve things and only
1162  * do this for the last write to a file, but the required bookkeeping
1163  * doesn't seem worth the trouble.
1164  */
1166  if (pg_fsync(fd) != 0)
1169  errmsg("could not fsync file \"%s\": %m", path)));
1171 
1172  if (CloseTransientFile(fd) != 0)
1173  ereport(ERROR,
1175  errmsg("could not close file \"%s\": %m", path)));
1176 }
unsigned int uint32
Definition: c.h:442
#define PG_BINARY
Definition: c.h:1209
int errcode_for_file_access(void)
Definition: elog.c:881
int errmsg(const char *fmt,...)
Definition: elog.c:1069
#define ERROR
Definition: elog.h:39
#define ereport(elevel,...)
Definition: elog.h:149
int CloseTransientFile(int fd)
Definition: fd.c:2609
int data_sync_elevel(int elevel)
Definition: fd.c:3736
int pg_fsync(int fd)
Definition: fd.c:356
int OpenTransientFile(const char *fileName, int fileFlags)
Definition: fd.c:2433
#define MAXPGPATH
const void * data
#define pg_pwrite
Definition: port.h:226
#define snprintf
Definition: port.h:238
static int fd(const char *x, int i)
Definition: preproc-init.c:105
#define LOGICAL_REWRITE_FORMAT
Definition: rewriteheap.h:54
struct LogicalRewriteMappingData LogicalRewriteMappingData
TransactionId mapped_xid
Definition: heapam_xlog.h:391
@ WAIT_EVENT_LOGICAL_REWRITE_MAPPING_SYNC
Definition: wait_event.h:192
@ WAIT_EVENT_LOGICAL_REWRITE_MAPPING_WRITE
Definition: wait_event.h:193
@ WAIT_EVENT_LOGICAL_REWRITE_TRUNCATE
Definition: wait_event.h:195
static void pgstat_report_wait_start(uint32 wait_event_info)
Definition: wait_event.h:268
static void pgstat_report_wait_end(void)
Definition: wait_event.h:284
#define ftruncate(a, b)
Definition: win32_port.h:82
#define LSN_FORMAT_ARGS(lsn)
Definition: xlogdefs.h:43
#define XLogRecGetXid(decoder)
Definition: xlogreader.h:413

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

Referenced by heap2_redo().

◆ HeapTupleHeaderAdvanceConflictHorizon()

void HeapTupleHeaderAdvanceConflictHorizon ( HeapTupleHeader  tuple,
TransactionId snapshotConflictHorizon 
)

Definition at line 7419 of file heapam.c.

7421 {
7422  TransactionId xmin = HeapTupleHeaderGetXmin(tuple);
7424  TransactionId xvac = HeapTupleHeaderGetXvac(tuple);
7425 
7426  if (tuple->t_infomask & HEAP_MOVED)
7427  {
7428  if (TransactionIdPrecedes(*snapshotConflictHorizon, xvac))
7429  *snapshotConflictHorizon = xvac;
7430  }
7431 
7432  /*
7433  * Ignore tuples inserted by an aborted transaction or if the tuple was
7434  * updated/deleted by the inserting transaction.
7435  *
7436  * Look for a committed hint bit, or if no xmin bit is set, check clog.
7437  */
7438  if (HeapTupleHeaderXminCommitted(tuple) ||
7440  {
7441  if (xmax != xmin &&
7442  TransactionIdFollows(xmax, *snapshotConflictHorizon))
7443  *snapshotConflictHorizon = xmax;
7444  }
7445 }
uint32 TransactionId
Definition: c.h:588
#define HeapTupleHeaderGetXvac(tup)
Definition: htup_details.h:410
#define HeapTupleHeaderGetXmin(tup)
Definition: htup_details.h:308
#define HEAP_MOVED
Definition: htup_details.h:212
#define HeapTupleHeaderXminCommitted(tup)
Definition: htup_details.h:319
#define HeapTupleHeaderGetUpdateXid(tup)
Definition: htup_details.h:360
#define HeapTupleHeaderXminInvalid(tup)
Definition: htup_details.h:324
bool TransactionIdDidCommit(TransactionId transactionId)
Definition: transam.c:125
bool TransactionIdPrecedes(TransactionId id1, TransactionId id2)
Definition: transam.c:273
bool TransactionIdFollows(TransactionId id1, TransactionId id2)
Definition: transam.c:307

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

Referenced by heap_index_delete_tuples(), and heap_prune_chain().

◆ log_heap_visible()

XLogRecPtr log_heap_visible ( RelFileLocator  rlocator,
Buffer  heap_buffer,
Buffer  vm_buffer,
TransactionId  snapshotConflictHorizon,
uint8  vmflags 
)

Definition at line 8251 of file heapam.c.

8253 {
8254  xl_heap_visible xlrec;
8255  XLogRecPtr recptr;
8256  uint8 flags;
8257 
8258  Assert(BufferIsValid(heap_buffer));
8259  Assert(BufferIsValid(vm_buffer));
8260 
8261  xlrec.snapshotConflictHorizon = snapshotConflictHorizon;
8262  xlrec.flags = vmflags;
8263  XLogBeginInsert();
8264  XLogRegisterData((char *) &xlrec, SizeOfHeapVisible);
8265 
8266  XLogRegisterBuffer(0, vm_buffer, 0);
8267 
8268  flags = REGBUF_STANDARD;
8269  if (!XLogHintBitIsNeeded())
8270  flags |= REGBUF_NO_IMAGE;
8271  XLogRegisterBuffer(1, heap_buffer, flags);
8272 
8273  recptr = XLogInsert(RM_HEAP2_ID, XLOG_HEAP2_VISIBLE);
8274 
8275  return recptr;
8276 }
static bool BufferIsValid(Buffer bufnum)
Definition: bufmgr.h:228
#define SizeOfHeapVisible
Definition: heapam_xlog.h:366
Assert(fmt[strlen(fmt) - 1] !='\n')
#define XLogHintBitIsNeeded()
Definition: xlog.h:115
uint64 XLogRecPtr
Definition: xlogdefs.h:21
void XLogRegisterData(char *data, uint32 len)
Definition: xloginsert.c:351
XLogRecPtr XLogInsert(RmgrId rmid, uint8 info)
Definition: xloginsert.c:451
void XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags)
Definition: xloginsert.c:243
void XLogBeginInsert(void)
Definition: xloginsert.c:150
#define REGBUF_STANDARD
Definition: xloginsert.h:34
#define REGBUF_NO_IMAGE
Definition: xloginsert.h:32

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

Referenced by visibilitymap_set().