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  xlhp_freeze_plan
 
struct  xlhp_freeze_plans
 
struct  xlhp_prune_items
 
struct  xl_heap_lock
 
struct  xl_heap_lock_updated
 
struct  xl_heap_confirm
 
struct  xl_heap_inplace
 
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_ON_ACCESS   0x10
 
#define XLOG_HEAP2_PRUNE_VACUUM_SCAN   0x20
 
#define XLOG_HEAP2_PRUNE_VACUUM_CLEANUP   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, flags) + sizeof(uint8))
 
#define XLHP_IS_CATALOG_REL   (1 << 1)
 
#define XLHP_CLEANUP_LOCK   (1 << 2)
 
#define XLHP_HAS_CONFLICT_HORIZON   (1 << 3)
 
#define XLHP_HAS_FREEZE_PLANS   (1 << 4)
 
#define XLHP_HAS_REDIRECTIONS   (1 << 5)
 
#define XLHP_HAS_DEAD_ITEMS   (1 << 6)
 
#define XLHP_HAS_NOW_UNUSED_ITEMS   (1 << 7)
 
#define XLH_FREEZE_XVAC   0x02
 
#define XLH_INVALID_XVAC   0x04
 
#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(uint8))
 
#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 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 xlhp_freeze_plan xlhp_freeze_plan
 
typedef struct xlhp_freeze_plans xlhp_freeze_plans
 
typedef struct xlhp_prune_items xlhp_prune_items
 
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_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 (Relation rel, Buffer heap_buffer, Buffer vm_buffer, TransactionId snapshotConflictHorizon, uint8 vmflags)
 
void heap_xlog_deserialize_prune_and_freeze (char *cursor, uint8 flags, int *nplans, xlhp_freeze_plan **plans, OffsetNumber **frz_offsets, int *nredirected, OffsetNumber **redirected, int *ndead, OffsetNumber **nowdead, int *nunused, OffsetNumber **nowunused)
 

Macro Definition Documentation

◆ SizeOfHeapConfirm

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

Definition at line 422 of file heapam_xlog.h.

◆ SizeOfHeapDelete

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

Definition at line 120 of file heapam_xlog.h.

◆ SizeOfHeapHeader

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

Definition at line 156 of file heapam_xlog.h.

◆ SizeOfHeapInplace

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

Definition at line 431 of file heapam_xlog.h.

◆ SizeOfHeapInsert

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

Definition at line 167 of file heapam_xlog.h.

◆ SizeOfHeapLock

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

Definition at line 403 of file heapam_xlog.h.

◆ SizeOfHeapLockUpdated

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

Definition at line 414 of file heapam_xlog.h.

◆ SizeOfHeapMultiInsert

#define SizeOfHeapMultiInsert   offsetof(xl_heap_multi_insert, offsets)

Definition at line 187 of file heapam_xlog.h.

◆ SizeOfHeapNewCid

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

Definition at line 465 of file heapam_xlog.h.

◆ SizeOfHeapPrune

#define SizeOfHeapPrune   (offsetof(xl_heap_prune, flags) + sizeof(uint8))

Definition at line 295 of file heapam_xlog.h.

◆ SizeOfHeapTruncate

#define SizeOfHeapTruncate   (offsetof(xl_heap_truncate, relids))

Definition at line 141 of file heapam_xlog.h.

◆ SizeOfHeapUpdate

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

Definition at line 232 of file heapam_xlog.h.

◆ SizeOfHeapVisible

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

Definition at line 445 of file heapam_xlog.h.

◆ SizeOfMultiInsertTuple

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

Definition at line 198 of file heapam_xlog.h.

◆ XLH_DELETE_ALL_VISIBLE_CLEARED

#define XLH_DELETE_ALL_VISIBLE_CLEARED   (1<<0)

Definition at line 101 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 108 of file heapam_xlog.h.

◆ XLH_DELETE_CONTAINS_OLD_KEY

#define XLH_DELETE_CONTAINS_OLD_KEY   (1<<2)

Definition at line 103 of file heapam_xlog.h.

◆ XLH_DELETE_CONTAINS_OLD_TUPLE

#define XLH_DELETE_CONTAINS_OLD_TUPLE   (1<<1)

Definition at line 102 of file heapam_xlog.h.

◆ XLH_DELETE_IS_PARTITION_MOVE

#define XLH_DELETE_IS_PARTITION_MOVE   (1<<4)

Definition at line 105 of file heapam_xlog.h.

◆ XLH_DELETE_IS_SUPER

#define XLH_DELETE_IS_SUPER   (1<<3)

Definition at line 104 of file heapam_xlog.h.

◆ XLH_FREEZE_XVAC

#define XLH_FREEZE_XVAC   0x02

Definition at line 338 of file heapam_xlog.h.

◆ XLH_INSERT_ALL_FROZEN_SET

#define XLH_INSERT_ALL_FROZEN_SET   (1<<5)

Definition at line 78 of file heapam_xlog.h.

◆ XLH_INSERT_ALL_VISIBLE_CLEARED

#define XLH_INSERT_ALL_VISIBLE_CLEARED   (1<<0)

Definition at line 71 of file heapam_xlog.h.

◆ XLH_INSERT_CONTAINS_NEW_TUPLE

#define XLH_INSERT_CONTAINS_NEW_TUPLE   (1<<3)

Definition at line 74 of file heapam_xlog.h.

◆ XLH_INSERT_IS_SPECULATIVE

#define XLH_INSERT_IS_SPECULATIVE   (1<<2)

Definition at line 73 of file heapam_xlog.h.

◆ XLH_INSERT_LAST_IN_MULTI

#define XLH_INSERT_LAST_IN_MULTI   (1<<1)

Definition at line 72 of file heapam_xlog.h.

◆ XLH_INSERT_ON_TOAST_RELATION

#define XLH_INSERT_ON_TOAST_RELATION   (1<<4)

Definition at line 75 of file heapam_xlog.h.

◆ XLH_INVALID_XVAC

#define XLH_INVALID_XVAC   0x04

Definition at line 339 of file heapam_xlog.h.

◆ XLH_LOCK_ALL_FROZEN_CLEARED

#define XLH_LOCK_ALL_FROZEN_CLEARED   0x01

Definition at line 392 of file heapam_xlog.h.

◆ XLH_TRUNCATE_CASCADE

#define XLH_TRUNCATE_CASCADE   (1<<0)

Definition at line 125 of file heapam_xlog.h.

◆ XLH_TRUNCATE_RESTART_SEQS

#define XLH_TRUNCATE_RESTART_SEQS   (1<<1)

Definition at line 126 of file heapam_xlog.h.

◆ XLH_UPDATE_CONTAINS_NEW_TUPLE

#define XLH_UPDATE_CONTAINS_NEW_TUPLE   (1<<4)

Definition at line 89 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 94 of file heapam_xlog.h.

◆ XLH_UPDATE_CONTAINS_OLD_KEY

#define XLH_UPDATE_CONTAINS_OLD_KEY   (1<<3)

Definition at line 88 of file heapam_xlog.h.

◆ XLH_UPDATE_CONTAINS_OLD_TUPLE

#define XLH_UPDATE_CONTAINS_OLD_TUPLE   (1<<2)

Definition at line 87 of file heapam_xlog.h.

◆ XLH_UPDATE_NEW_ALL_VISIBLE_CLEARED

#define XLH_UPDATE_NEW_ALL_VISIBLE_CLEARED   (1<<1)

Definition at line 86 of file heapam_xlog.h.

◆ XLH_UPDATE_OLD_ALL_VISIBLE_CLEARED

#define XLH_UPDATE_OLD_ALL_VISIBLE_CLEARED   (1<<0)

Definition at line 84 of file heapam_xlog.h.

◆ XLH_UPDATE_PREFIX_FROM_OLD

#define XLH_UPDATE_PREFIX_FROM_OLD   (1<<5)

Definition at line 90 of file heapam_xlog.h.

◆ XLH_UPDATE_SUFFIX_FROM_OLD

#define XLH_UPDATE_SUFFIX_FROM_OLD   (1<<6)

Definition at line 91 of file heapam_xlog.h.

◆ XLHL_KEYS_UPDATED

#define XLHL_KEYS_UPDATED   0x10

Definition at line 389 of file heapam_xlog.h.

◆ XLHL_XMAX_EXCL_LOCK

#define XLHL_XMAX_EXCL_LOCK   0x04

Definition at line 387 of file heapam_xlog.h.

◆ XLHL_XMAX_IS_MULTI

#define XLHL_XMAX_IS_MULTI   0x01

Definition at line 385 of file heapam_xlog.h.

◆ XLHL_XMAX_KEYSHR_LOCK

#define XLHL_XMAX_KEYSHR_LOCK   0x08

Definition at line 388 of file heapam_xlog.h.

◆ XLHL_XMAX_LOCK_ONLY

#define XLHL_XMAX_LOCK_ONLY   0x02

Definition at line 386 of file heapam_xlog.h.

◆ XLHP_CLEANUP_LOCK

#define XLHP_CLEANUP_LOCK   (1 << 2)

Definition at line 308 of file heapam_xlog.h.

◆ XLHP_HAS_CONFLICT_HORIZON

#define XLHP_HAS_CONFLICT_HORIZON   (1 << 3)

Definition at line 316 of file heapam_xlog.h.

◆ XLHP_HAS_DEAD_ITEMS

#define XLHP_HAS_DEAD_ITEMS   (1 << 6)

Definition at line 330 of file heapam_xlog.h.

◆ XLHP_HAS_FREEZE_PLANS

#define XLHP_HAS_FREEZE_PLANS   (1 << 4)

Definition at line 322 of file heapam_xlog.h.

◆ XLHP_HAS_NOW_UNUSED_ITEMS

#define XLHP_HAS_NOW_UNUSED_ITEMS   (1 << 7)

Definition at line 331 of file heapam_xlog.h.

◆ XLHP_HAS_REDIRECTIONS

#define XLHP_HAS_REDIRECTIONS   (1 << 5)

Definition at line 329 of file heapam_xlog.h.

◆ XLHP_IS_CATALOG_REL

#define XLHP_IS_CATALOG_REL   (1 << 1)

Definition at line 298 of file heapam_xlog.h.

◆ XLOG_HEAP2_LOCK_UPDATED

#define XLOG_HEAP2_LOCK_UPDATED   0x60

Definition at line 64 of file heapam_xlog.h.

◆ XLOG_HEAP2_MULTI_INSERT

#define XLOG_HEAP2_MULTI_INSERT   0x50

Definition at line 63 of file heapam_xlog.h.

◆ XLOG_HEAP2_NEW_CID

#define XLOG_HEAP2_NEW_CID   0x70

Definition at line 65 of file heapam_xlog.h.

◆ XLOG_HEAP2_PRUNE_ON_ACCESS

#define XLOG_HEAP2_PRUNE_ON_ACCESS   0x10

Definition at line 59 of file heapam_xlog.h.

◆ XLOG_HEAP2_PRUNE_VACUUM_CLEANUP

#define XLOG_HEAP2_PRUNE_VACUUM_CLEANUP   0x30

Definition at line 61 of file heapam_xlog.h.

◆ XLOG_HEAP2_PRUNE_VACUUM_SCAN

#define XLOG_HEAP2_PRUNE_VACUUM_SCAN   0x20

Definition at line 60 of file heapam_xlog.h.

◆ XLOG_HEAP2_REWRITE

#define XLOG_HEAP2_REWRITE   0x00

Definition at line 58 of file heapam_xlog.h.

◆ XLOG_HEAP2_VISIBLE

#define XLOG_HEAP2_VISIBLE   0x40

Definition at line 62 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_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_visible

◆ xl_multi_insert_tuple

◆ xlhp_freeze_plan

◆ xlhp_freeze_plans

◆ xlhp_prune_items

Function Documentation

◆ heap2_desc()

void heap2_desc ( StringInfo  buf,
XLogReaderState record 
)

Definition at line 260 of file heapdesc.c.

261 {
262  char *rec = XLogRecGetData(record);
263  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
264 
265  info &= XLOG_HEAP_OPMASK;
266  if (info == XLOG_HEAP2_PRUNE_ON_ACCESS ||
269  {
270  xl_heap_prune *xlrec = (xl_heap_prune *) rec;
271 
272  if (xlrec->flags & XLHP_HAS_CONFLICT_HORIZON)
273  {
274  TransactionId conflict_xid;
275 
276  memcpy(&conflict_xid, rec + SizeOfHeapPrune, sizeof(TransactionId));
277 
278  appendStringInfo(buf, "snapshotConflictHorizon: %u",
279  conflict_xid);
280  }
281 
282  appendStringInfo(buf, ", isCatalogRel: %c",
283  xlrec->flags & XLHP_IS_CATALOG_REL ? 'T' : 'F');
284 
285  if (XLogRecHasBlockData(record, 0))
286  {
287  Size datalen;
288  OffsetNumber *redirected;
289  OffsetNumber *nowdead;
290  OffsetNumber *nowunused;
291  int nredirected;
292  int nunused;
293  int ndead;
294  int nplans;
295  xlhp_freeze_plan *plans;
296  OffsetNumber *frz_offsets;
297 
298  char *cursor = XLogRecGetBlockData(record, 0, &datalen);
299 
301  &nplans, &plans, &frz_offsets,
302  &nredirected, &redirected,
303  &ndead, &nowdead,
304  &nunused, &nowunused);
305 
306  appendStringInfo(buf, ", nplans: %u, nredirected: %u, ndead: %u, nunused: %u",
307  nplans, nredirected, ndead, nunused);
308 
309  if (nplans > 0)
310  {
311  appendStringInfoString(buf, ", plans:");
312  array_desc(buf, plans, sizeof(xlhp_freeze_plan), nplans,
313  &plan_elem_desc, &frz_offsets);
314  }
315 
316  if (nredirected > 0)
317  {
318  appendStringInfoString(buf, ", redirected:");
319  array_desc(buf, redirected, sizeof(OffsetNumber) * 2,
320  nredirected, &redirect_elem_desc, NULL);
321  }
322 
323  if (ndead > 0)
324  {
325  appendStringInfoString(buf, ", dead:");
326  array_desc(buf, nowdead, sizeof(OffsetNumber), ndead,
327  &offset_elem_desc, NULL);
328  }
329 
330  if (nunused > 0)
331  {
332  appendStringInfoString(buf, ", unused:");
333  array_desc(buf, nowunused, sizeof(OffsetNumber), nunused,
334  &offset_elem_desc, NULL);
335  }
336  }
337  }
338  else if (info == XLOG_HEAP2_VISIBLE)
339  {
340  xl_heap_visible *xlrec = (xl_heap_visible *) rec;
341 
342  appendStringInfo(buf, "snapshotConflictHorizon: %u, flags: 0x%02X",
343  xlrec->snapshotConflictHorizon, xlrec->flags);
344  }
345  else if (info == XLOG_HEAP2_MULTI_INSERT)
346  {
348  bool isinit = (XLogRecGetInfo(record) & XLOG_HEAP_INIT_PAGE) != 0;
349 
350  appendStringInfo(buf, "ntuples: %d, flags: 0x%02X", xlrec->ntuples,
351  xlrec->flags);
352 
353  if (XLogRecHasBlockData(record, 0) && !isinit)
354  {
355  appendStringInfoString(buf, ", offsets:");
356  array_desc(buf, xlrec->offsets, sizeof(OffsetNumber),
357  xlrec->ntuples, &offset_elem_desc, NULL);
358  }
359  }
360  else if (info == XLOG_HEAP2_LOCK_UPDATED)
361  {
363 
364  appendStringInfo(buf, "xmax: %u, off: %u, ",
365  xlrec->xmax, xlrec->offnum);
366  infobits_desc(buf, xlrec->infobits_set, "infobits");
367  appendStringInfo(buf, ", flags: 0x%02X", xlrec->flags);
368  }
369  else if (info == XLOG_HEAP2_NEW_CID)
370  {
371  xl_heap_new_cid *xlrec = (xl_heap_new_cid *) rec;
372 
373  appendStringInfo(buf, "rel: %u/%u/%u, tid: %u/%u",
374  xlrec->target_locator.spcOid,
375  xlrec->target_locator.dbOid,
376  xlrec->target_locator.relNumber,
379  appendStringInfo(buf, ", cmin: %u, cmax: %u, combo: %u",
380  xlrec->cmin, xlrec->cmax, xlrec->combocid);
381  }
382 }
unsigned char uint8
Definition: c.h:504
uint32 TransactionId
Definition: c.h:652
size_t Size
Definition: c.h:605
#define XLOG_HEAP2_MULTI_INSERT
Definition: heapam_xlog.h:63
#define XLHP_HAS_CONFLICT_HORIZON
Definition: heapam_xlog.h:316
#define XLOG_HEAP_OPMASK
Definition: heapam_xlog.h:41
#define SizeOfHeapPrune
Definition: heapam_xlog.h:295
#define XLOG_HEAP2_PRUNE_VACUUM_SCAN
Definition: heapam_xlog.h:60
#define XLOG_HEAP2_LOCK_UPDATED
Definition: heapam_xlog.h:64
#define XLOG_HEAP2_PRUNE_ON_ACCESS
Definition: heapam_xlog.h:59
#define XLOG_HEAP2_NEW_CID
Definition: heapam_xlog.h:65
#define XLOG_HEAP2_PRUNE_VACUUM_CLEANUP
Definition: heapam_xlog.h:61
#define XLOG_HEAP2_VISIBLE
Definition: heapam_xlog.h:62
#define XLHP_IS_CATALOG_REL
Definition: heapam_xlog.h:298
#define XLOG_HEAP_INIT_PAGE
Definition: heapam_xlog.h:46
void heap_xlog_deserialize_prune_and_freeze(char *cursor, uint8 flags, int *nplans, xlhp_freeze_plan **plans, OffsetNumber **frz_offsets, int *nredirected, OffsetNumber **redirected, int *ndead, OffsetNumber **nowdead, int *nunused, OffsetNumber **nowunused)
Definition: heapdesc.c:104
static void plan_elem_desc(StringInfo buf, void *plan, void *data)
Definition: heapdesc.c:75
static void infobits_desc(StringInfo buf, uint8 infobits, const char *keyname)
Definition: heapdesc.c:25
static OffsetNumber ItemPointerGetOffsetNumber(const ItemPointerData *pointer)
Definition: itemptr.h:124
static BlockNumber ItemPointerGetBlockNumber(const ItemPointerData *pointer)
Definition: itemptr.h:103
uint16 OffsetNumber
Definition: off.h:24
static char * buf
Definition: pg_test_fsync.c:73
void redirect_elem_desc(StringInfo buf, void *offset, void *data)
void array_desc(StringInfo buf, void *array, size_t elem_size, int count, void(*elem_desc)(StringInfo buf, void *elem, void *data), void *data)
void offset_elem_desc(StringInfo buf, void *offset, void *data)
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:97
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:182
RelFileNumber relNumber
Definition: type.h:137
TransactionId xmax
Definition: heapam_xlog.h:408
OffsetNumber offnum
Definition: heapam_xlog.h:409
OffsetNumber offsets[FLEXIBLE_ARRAY_MEMBER]
Definition: heapam_xlog.h:184
CommandId cmin
Definition: heapam_xlog.h:454
CommandId combocid
Definition: heapam_xlog.h:456
ItemPointerData target_tid
Definition: heapam_xlog.h:462
CommandId cmax
Definition: heapam_xlog.h:455
RelFileLocator target_locator
Definition: heapam_xlog.h:461
TransactionId snapshotConflictHorizon
Definition: heapam_xlog.h:441
char * XLogRecGetBlockData(XLogReaderState *record, uint8 block_id, Size *len)
Definition: xlogreader.c:2025
#define XLogRecHasBlockData(decoder, block_id)
Definition: xlogreader.h:427
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:410
#define XLogRecGetData(decoder)
Definition: xlogreader.h:415
#define XLR_INFO_MASK
Definition: xlogrecord.h:62

References appendStringInfo(), appendStringInfoString(), array_desc(), 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_prune::flags, xl_heap_lock_updated::flags, xl_heap_visible::flags, heap_xlog_deserialize_prune_and_freeze(), infobits_desc(), xl_heap_lock_updated::infobits_set, ItemPointerGetBlockNumber(), ItemPointerGetOffsetNumber(), xl_heap_multi_insert::ntuples, xl_heap_lock_updated::offnum, offset_elem_desc(), xl_heap_multi_insert::offsets, plan_elem_desc(), redirect_elem_desc(), RelFileLocator::relNumber, SizeOfHeapPrune, xl_heap_visible::snapshotConflictHorizon, RelFileLocator::spcOid, xl_heap_new_cid::target_locator, xl_heap_new_cid::target_tid, XLHP_HAS_CONFLICT_HORIZON, XLHP_IS_CATALOG_REL, XLOG_HEAP2_LOCK_UPDATED, XLOG_HEAP2_MULTI_INSERT, XLOG_HEAP2_NEW_CID, XLOG_HEAP2_PRUNE_ON_ACCESS, XLOG_HEAP2_PRUNE_VACUUM_CLEANUP, XLOG_HEAP2_PRUNE_VACUUM_SCAN, XLOG_HEAP2_VISIBLE, XLOG_HEAP_INIT_PAGE, XLOG_HEAP_OPMASK, XLogRecGetBlockData(), XLogRecGetData, XLogRecGetInfo, XLogRecHasBlockData, XLR_INFO_MASK, and xl_heap_lock_updated::xmax.

◆ heap2_identify()

const char* heap2_identify ( uint8  info)

Definition at line 430 of file heapdesc.c.

431 {
432  const char *id = NULL;
433 
434  switch (info & ~XLR_INFO_MASK)
435  {
437  id = "PRUNE_ON_ACCESS";
438  break;
440  id = "PRUNE_VACUUM_SCAN";
441  break;
443  id = "PRUNE_VACUUM_CLEANUP";
444  break;
445  case XLOG_HEAP2_VISIBLE:
446  id = "VISIBLE";
447  break;
449  id = "MULTI_INSERT";
450  break;
452  id = "MULTI_INSERT+INIT";
453  break;
455  id = "LOCK_UPDATED";
456  break;
457  case XLOG_HEAP2_NEW_CID:
458  id = "NEW_CID";
459  break;
460  case XLOG_HEAP2_REWRITE:
461  id = "REWRITE";
462  break;
463  }
464 
465  return id;
466 }
#define XLOG_HEAP2_REWRITE
Definition: heapam_xlog.h:58

References XLOG_HEAP2_LOCK_UPDATED, XLOG_HEAP2_MULTI_INSERT, XLOG_HEAP2_NEW_CID, XLOG_HEAP2_PRUNE_ON_ACCESS, XLOG_HEAP2_PRUNE_VACUUM_CLEANUP, XLOG_HEAP2_PRUNE_VACUUM_SCAN, XLOG_HEAP2_REWRITE, XLOG_HEAP2_VISIBLE, XLOG_HEAP_INIT_PAGE, and XLR_INFO_MASK.

◆ heap2_redo()

void heap2_redo ( XLogReaderState record)

Definition at line 9917 of file heapam.c.

9918 {
9919  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
9920 
9921  switch (info & XLOG_HEAP_OPMASK)
9922  {
9926  heap_xlog_prune_freeze(record);
9927  break;
9928  case XLOG_HEAP2_VISIBLE:
9929  heap_xlog_visible(record);
9930  break;
9932  heap_xlog_multi_insert(record);
9933  break;
9935  heap_xlog_lock_updated(record);
9936  break;
9937  case XLOG_HEAP2_NEW_CID:
9938 
9939  /*
9940  * Nothing to do on a real replay, only used during logical
9941  * decoding.
9942  */
9943  break;
9944  case XLOG_HEAP2_REWRITE:
9945  heap_xlog_logical_rewrite(record);
9946  break;
9947  default:
9948  elog(PANIC, "heap2_redo: unknown op code %u", info);
9949  }
9950 }
#define PANIC
Definition: elog.h:42
#define elog(elevel,...)
Definition: elog.h:224
static void heap_xlog_prune_freeze(XLogReaderState *record)
Definition: heapam.c:8743
static void heap_xlog_lock_updated(XLogReaderState *record)
Definition: heapam.c:9770
static void heap_xlog_multi_insert(XLogReaderState *record)
Definition: heapam.c:9244
static void heap_xlog_visible(XLogReaderState *record)
Definition: heapam.c:8895
void heap_xlog_logical_rewrite(XLogReaderState *r)
Definition: rewriteheap.c:1073

References elog, heap_xlog_lock_updated(), heap_xlog_logical_rewrite(), heap_xlog_multi_insert(), heap_xlog_prune_freeze(), heap_xlog_visible(), PANIC, XLOG_HEAP2_LOCK_UPDATED, XLOG_HEAP2_MULTI_INSERT, XLOG_HEAP2_NEW_CID, XLOG_HEAP2_PRUNE_ON_ACCESS, XLOG_HEAP2_PRUNE_VACUUM_CLEANUP, XLOG_HEAP2_PRUNE_VACUUM_SCAN, XLOG_HEAP2_REWRITE, XLOG_HEAP2_VISIBLE, XLOG_HEAP_OPMASK, XLogRecGetInfo, and XLR_INFO_MASK.

◆ heap_desc()

void heap_desc ( StringInfo  buf,
XLogReaderState record 
)

Definition at line 183 of file heapdesc.c.

184 {
185  char *rec = XLogRecGetData(record);
186  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
187 
188  info &= XLOG_HEAP_OPMASK;
189  if (info == XLOG_HEAP_INSERT)
190  {
191  xl_heap_insert *xlrec = (xl_heap_insert *) rec;
192 
193  appendStringInfo(buf, "off: %u, flags: 0x%02X",
194  xlrec->offnum,
195  xlrec->flags);
196  }
197  else if (info == XLOG_HEAP_DELETE)
198  {
199  xl_heap_delete *xlrec = (xl_heap_delete *) rec;
200 
201  appendStringInfo(buf, "xmax: %u, off: %u, ",
202  xlrec->xmax, xlrec->offnum);
203  infobits_desc(buf, xlrec->infobits_set, "infobits");
204  appendStringInfo(buf, ", flags: 0x%02X", xlrec->flags);
205  }
206  else if (info == XLOG_HEAP_UPDATE)
207  {
208  xl_heap_update *xlrec = (xl_heap_update *) rec;
209 
210  appendStringInfo(buf, "old_xmax: %u, old_off: %u, ",
211  xlrec->old_xmax, xlrec->old_offnum);
212  infobits_desc(buf, xlrec->old_infobits_set, "old_infobits");
213  appendStringInfo(buf, ", flags: 0x%02X, new_xmax: %u, new_off: %u",
214  xlrec->flags, xlrec->new_xmax, xlrec->new_offnum);
215  }
216  else if (info == XLOG_HEAP_HOT_UPDATE)
217  {
218  xl_heap_update *xlrec = (xl_heap_update *) rec;
219 
220  appendStringInfo(buf, "old_xmax: %u, old_off: %u, ",
221  xlrec->old_xmax, xlrec->old_offnum);
222  infobits_desc(buf, xlrec->old_infobits_set, "old_infobits");
223  appendStringInfo(buf, ", flags: 0x%02X, new_xmax: %u, new_off: %u",
224  xlrec->flags, xlrec->new_xmax, xlrec->new_offnum);
225  }
226  else if (info == XLOG_HEAP_TRUNCATE)
227  {
228  xl_heap_truncate *xlrec = (xl_heap_truncate *) rec;
229 
230  truncate_flags_desc(buf, xlrec->flags);
231  appendStringInfo(buf, ", nrelids: %u", xlrec->nrelids);
232  appendStringInfoString(buf, ", relids:");
233  array_desc(buf, xlrec->relids, sizeof(Oid), xlrec->nrelids,
234  &oid_elem_desc, NULL);
235  }
236  else if (info == XLOG_HEAP_CONFIRM)
237  {
238  xl_heap_confirm *xlrec = (xl_heap_confirm *) rec;
239 
240  appendStringInfo(buf, "off: %u", xlrec->offnum);
241  }
242  else if (info == XLOG_HEAP_LOCK)
243  {
244  xl_heap_lock *xlrec = (xl_heap_lock *) rec;
245 
246  appendStringInfo(buf, "xmax: %u, off: %u, ",
247  xlrec->xmax, xlrec->offnum);
248  infobits_desc(buf, xlrec->infobits_set, "infobits");
249  appendStringInfo(buf, ", flags: 0x%02X", xlrec->flags);
250  }
251  else if (info == XLOG_HEAP_INPLACE)
252  {
253  xl_heap_inplace *xlrec = (xl_heap_inplace *) rec;
254 
255  appendStringInfo(buf, "off: %u", xlrec->offnum);
256  }
257 }
#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 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_INSERT
Definition: heapam_xlog.h:32
#define XLOG_HEAP_CONFIRM
Definition: heapam_xlog.h:37
static void truncate_flags_desc(StringInfo buf, uint8 flags)
Definition: heapdesc.c:54
unsigned int Oid
Definition: postgres_ext.h:31
void oid_elem_desc(StringInfo buf, void *relid, void *data)
OffsetNumber offnum
Definition: heapam_xlog.h:419
TransactionId xmax
Definition: heapam_xlog.h:114
OffsetNumber offnum
Definition: heapam_xlog.h:115
uint8 infobits_set
Definition: heapam_xlog.h:116
OffsetNumber offnum
Definition: heapam_xlog.h:427
OffsetNumber offnum
Definition: heapam_xlog.h:161
uint8 infobits_set
Definition: heapam_xlog.h:399
OffsetNumber offnum
Definition: heapam_xlog.h:398
TransactionId xmax
Definition: heapam_xlog.h:397
Oid relids[FLEXIBLE_ARRAY_MEMBER]
Definition: heapam_xlog.h:138
TransactionId new_xmax
Definition: heapam_xlog.h:223
uint8 old_infobits_set
Definition: heapam_xlog.h:221
TransactionId old_xmax
Definition: heapam_xlog.h:219
OffsetNumber old_offnum
Definition: heapam_xlog.h:220
OffsetNumber new_offnum
Definition: heapam_xlog.h:224

References appendStringInfo(), appendStringInfoString(), array_desc(), buf, xl_heap_delete::flags, xl_heap_truncate::flags, xl_heap_insert::flags, xl_heap_update::flags, xl_heap_lock::flags, infobits_desc(), xl_heap_delete::infobits_set, xl_heap_lock::infobits_set, 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, oid_elem_desc(), xl_heap_update::old_infobits_set, xl_heap_update::old_offnum, xl_heap_update::old_xmax, xl_heap_truncate::relids, truncate_flags_desc(), 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, XLR_INFO_MASK, xl_heap_delete::xmax, and xl_heap_lock::xmax.

◆ heap_identify()

const char* heap_identify ( uint8  info)

Definition at line 385 of file heapdesc.c.

386 {
387  const char *id = NULL;
388 
389  switch (info & ~XLR_INFO_MASK)
390  {
391  case XLOG_HEAP_INSERT:
392  id = "INSERT";
393  break;
395  id = "INSERT+INIT";
396  break;
397  case XLOG_HEAP_DELETE:
398  id = "DELETE";
399  break;
400  case XLOG_HEAP_UPDATE:
401  id = "UPDATE";
402  break;
404  id = "UPDATE+INIT";
405  break;
407  id = "HOT_UPDATE";
408  break;
410  id = "HOT_UPDATE+INIT";
411  break;
412  case XLOG_HEAP_TRUNCATE:
413  id = "TRUNCATE";
414  break;
415  case XLOG_HEAP_CONFIRM:
416  id = "HEAP_CONFIRM";
417  break;
418  case XLOG_HEAP_LOCK:
419  id = "LOCK";
420  break;
421  case XLOG_HEAP_INPLACE:
422  id = "INPLACE";
423  break;
424  }
425 
426  return id;
427 }

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 9956 of file heapam.c.

9957 {
9958  Page page = (Page) pagedata;
9959  OffsetNumber off;
9960 
9962 
9963  mask_page_hint_bits(page);
9964  mask_unused_space(page);
9965 
9966  for (off = 1; off <= PageGetMaxOffsetNumber(page); off++)
9967  {
9968  ItemId iid = PageGetItemId(page, off);
9969  char *page_item;
9970 
9971  page_item = (char *) (page + ItemIdGetOffset(iid));
9972 
9973  if (ItemIdIsNormal(iid))
9974  {
9975  HeapTupleHeader page_htup = (HeapTupleHeader) page_item;
9976 
9977  /*
9978  * If xmin of a tuple is not yet frozen, we should ignore
9979  * differences in hint bits, since they can be set without
9980  * emitting WAL.
9981  */
9982  if (!HeapTupleHeaderXminFrozen(page_htup))
9983  page_htup->t_infomask &= ~HEAP_XACT_MASK;
9984  else
9985  {
9986  /* Still we need to mask xmax hint bits. */
9987  page_htup->t_infomask &= ~HEAP_XMAX_INVALID;
9988  page_htup->t_infomask &= ~HEAP_XMAX_COMMITTED;
9989  }
9990 
9991  /*
9992  * During replay, we set Command Id to FirstCommandId. Hence, mask
9993  * it. See heap_xlog_insert() for details.
9994  */
9995  page_htup->t_choice.t_heap.t_field3.t_cid = MASK_MARKER;
9996 
9997  /*
9998  * For a speculative tuple, heap_insert() does not set ctid in the
9999  * caller-passed heap tuple itself, leaving the ctid field to
10000  * contain a speculative token value - a per-backend monotonically
10001  * increasing identifier. Besides, it does not WAL-log ctid under
10002  * any circumstances.
10003  *
10004  * During redo, heap_xlog_insert() sets t_ctid to current block
10005  * number and self offset number. It doesn't care about any
10006  * speculative insertions on the primary. Hence, we set t_ctid to
10007  * current block number and self offset number to ignore any
10008  * inconsistency.
10009  */
10010  if (HeapTupleHeaderIsSpeculative(page_htup))
10011  ItemPointerSet(&page_htup->t_ctid, blkno, off);
10012 
10013  /*
10014  * NB: Not ignoring ctid changes due to the tuple having moved
10015  * (i.e. HeapTupleHeaderIndicatesMovedPartitions), because that's
10016  * important information that needs to be in-sync between primary
10017  * and standby, and thus is WAL logged.
10018  */
10019  }
10020 
10021  /*
10022  * Ignore any padding bytes after the tuple, when the length of the
10023  * item is not MAXALIGNed.
10024  */
10025  if (ItemIdHasStorage(iid))
10026  {
10027  int len = ItemIdGetLength(iid);
10028  int padlen = MAXALIGN(len) - len;
10029 
10030  if (padlen > 0)
10031  memset(page_item + len, MASK_MARKER, padlen);
10032  }
10033  }
10034 }
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:811
HeapTupleHeaderData * HeapTupleHeader
Definition: htup.h:23
#define HEAP_XMAX_COMMITTED
Definition: htup_details.h:207
#define HEAP_XACT_MASK
Definition: htup_details.h:215
#define HeapTupleHeaderXminFrozen(tup)
Definition: htup_details.h:331
#define HEAP_XMAX_INVALID
Definition: htup_details.h:208
#define HeapTupleHeaderIsSpeculative(tup)
Definition: htup_details.h:428
#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
const void size_t len
union HeapTupleFields::@47 t_field3
CommandId t_cid
Definition: htup_details.h:129
ItemPointerData t_ctid
Definition: htup_details.h:161
HeapTupleFields t_heap
Definition: htup_details.h:157
union HeapTupleHeaderData::@48 t_choice

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 9871 of file heapam.c.

9872 {
9873  uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
9874 
9875  /*
9876  * These operations don't overwrite MVCC data so no conflict processing is
9877  * required. The ones in heap2 rmgr do.
9878  */
9879 
9880  switch (info & XLOG_HEAP_OPMASK)
9881  {
9882  case XLOG_HEAP_INSERT:
9883  heap_xlog_insert(record);
9884  break;
9885  case XLOG_HEAP_DELETE:
9886  heap_xlog_delete(record);
9887  break;
9888  case XLOG_HEAP_UPDATE:
9889  heap_xlog_update(record, false);
9890  break;
9891  case XLOG_HEAP_TRUNCATE:
9892 
9893  /*
9894  * TRUNCATE is a no-op because the actions are already logged as
9895  * SMGR WAL records. TRUNCATE WAL record only exists for logical
9896  * decoding.
9897  */
9898  break;
9899  case XLOG_HEAP_HOT_UPDATE:
9900  heap_xlog_update(record, true);
9901  break;
9902  case XLOG_HEAP_CONFIRM:
9903  heap_xlog_confirm(record);
9904  break;
9905  case XLOG_HEAP_LOCK:
9906  heap_xlog_lock(record);
9907  break;
9908  case XLOG_HEAP_INPLACE:
9909  heap_xlog_inplace(record);
9910  break;
9911  default:
9912  elog(PANIC, "heap_redo: unknown op code %u", info);
9913  }
9914 }
static void heap_xlog_insert(XLogReaderState *record)
Definition: heapam.c:9124
static void heap_xlog_update(XLogReaderState *record, bool hot_update)
Definition: heapam.c:9391
static void heap_xlog_delete(XLogReaderState *record)
Definition: heapam.c:9051
static void heap_xlog_lock(XLogReaderState *record)
Definition: heapam.c:9699
static void heap_xlog_inplace(XLogReaderState *record)
Definition: heapam.c:9830
static void heap_xlog_confirm(XLogReaderState *record)
Definition: heapam.c:9663

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

void heap_xlog_deserialize_prune_and_freeze ( char *  cursor,
uint8  flags,
int *  nplans,
xlhp_freeze_plan **  plans,
OffsetNumber **  frz_offsets,
int *  nredirected,
OffsetNumber **  redirected,
int *  ndead,
OffsetNumber **  nowdead,
int *  nunused,
OffsetNumber **  nowunused 
)

Definition at line 104 of file heapdesc.c.

110 {
111  if (flags & XLHP_HAS_FREEZE_PLANS)
112  {
113  xlhp_freeze_plans *freeze_plans = (xlhp_freeze_plans *) cursor;
114 
115  *nplans = freeze_plans->nplans;
116  Assert(*nplans > 0);
117  *plans = freeze_plans->plans;
118 
119  cursor += offsetof(xlhp_freeze_plans, plans);
120  cursor += sizeof(xlhp_freeze_plan) * *nplans;
121  }
122  else
123  {
124  *nplans = 0;
125  *plans = NULL;
126  }
127 
128  if (flags & XLHP_HAS_REDIRECTIONS)
129  {
130  xlhp_prune_items *subrecord = (xlhp_prune_items *) cursor;
131 
132  *nredirected = subrecord->ntargets;
133  Assert(*nredirected > 0);
134  *redirected = &subrecord->data[0];
135 
136  cursor += offsetof(xlhp_prune_items, data);
137  cursor += sizeof(OffsetNumber[2]) * *nredirected;
138  }
139  else
140  {
141  *nredirected = 0;
142  *redirected = NULL;
143  }
144 
145  if (flags & XLHP_HAS_DEAD_ITEMS)
146  {
147  xlhp_prune_items *subrecord = (xlhp_prune_items *) cursor;
148 
149  *ndead = subrecord->ntargets;
150  Assert(*ndead > 0);
151  *nowdead = subrecord->data;
152 
153  cursor += offsetof(xlhp_prune_items, data);
154  cursor += sizeof(OffsetNumber) * *ndead;
155  }
156  else
157  {
158  *ndead = 0;
159  *nowdead = NULL;
160  }
161 
162  if (flags & XLHP_HAS_NOW_UNUSED_ITEMS)
163  {
164  xlhp_prune_items *subrecord = (xlhp_prune_items *) cursor;
165 
166  *nunused = subrecord->ntargets;
167  Assert(*nunused > 0);
168  *nowunused = subrecord->data;
169 
170  cursor += offsetof(xlhp_prune_items, data);
171  cursor += sizeof(OffsetNumber) * *nunused;
172  }
173  else
174  {
175  *nunused = 0;
176  *nowunused = NULL;
177  }
178 
179  *frz_offsets = (OffsetNumber *) cursor;
180 }
#define Assert(condition)
Definition: c.h:858
struct xlhp_freeze_plan xlhp_freeze_plan
#define XLHP_HAS_FREEZE_PLANS
Definition: heapam_xlog.h:322
#define XLHP_HAS_NOW_UNUSED_ITEMS
Definition: heapam_xlog.h:331
#define XLHP_HAS_REDIRECTIONS
Definition: heapam_xlog.h:329
#define XLHP_HAS_DEAD_ITEMS
Definition: heapam_xlog.h:330
const void * data
xlhp_freeze_plan plans[FLEXIBLE_ARRAY_MEMBER]
Definition: heapam_xlog.h:367
OffsetNumber data[FLEXIBLE_ARRAY_MEMBER]
Definition: heapam_xlog.h:380

References Assert, xlhp_prune_items::data, data, xlhp_freeze_plans::nplans, xlhp_prune_items::ntargets, xlhp_freeze_plans::plans, XLHP_HAS_DEAD_ITEMS, XLHP_HAS_FREEZE_PLANS, XLHP_HAS_NOW_UNUSED_ITEMS, and XLHP_HAS_REDIRECTIONS.

Referenced by heap2_desc(), and heap_xlog_prune_freeze().

◆ heap_xlog_logical_rewrite()

void heap_xlog_logical_rewrite ( XLogReaderState r)

Definition at line 1073 of file rewriteheap.c.

1074 {
1075  char path[MAXPGPATH];
1076  int fd;
1077  xl_heap_rewrite_mapping *xlrec;
1078  uint32 len;
1079  char *data;
1080 
1081  xlrec = (xl_heap_rewrite_mapping *) XLogRecGetData(r);
1082 
1083  snprintf(path, MAXPGPATH,
1084  "pg_logical/mappings/" LOGICAL_REWRITE_FORMAT,
1085  xlrec->mapped_db, xlrec->mapped_rel,
1086  LSN_FORMAT_ARGS(xlrec->start_lsn),
1087  xlrec->mapped_xid, XLogRecGetXid(r));
1088 
1089  fd = OpenTransientFile(path,
1090  O_CREAT | O_WRONLY | PG_BINARY);
1091  if (fd < 0)
1092  ereport(ERROR,
1094  errmsg("could not create file \"%s\": %m", path)));
1095 
1096  /*
1097  * Truncate all data that's not guaranteed to have been safely fsynced (by
1098  * previous record or by the last checkpoint).
1099  */
1100  pgstat_report_wait_start(WAIT_EVENT_LOGICAL_REWRITE_TRUNCATE);
1101  if (ftruncate(fd, xlrec->offset) != 0)
1102  ereport(ERROR,
1104  errmsg("could not truncate file \"%s\" to %u: %m",
1105  path, (uint32) xlrec->offset)));
1107 
1108  data = XLogRecGetData(r) + sizeof(*xlrec);
1109 
1110  len = xlrec->num_mappings * sizeof(LogicalRewriteMappingData);
1111 
1112  /* write out tail end of mapping file (again) */
1113  errno = 0;
1114  pgstat_report_wait_start(WAIT_EVENT_LOGICAL_REWRITE_MAPPING_WRITE);
1115  if (pg_pwrite(fd, data, len, xlrec->offset) != len)
1116  {
1117  /* if write didn't set errno, assume problem is no disk space */
1118  if (errno == 0)
1119  errno = ENOSPC;
1120  ereport(ERROR,
1122  errmsg("could not write to file \"%s\": %m", path)));
1123  }
1125 
1126  /*
1127  * Now fsync all previously written data. We could improve things and only
1128  * do this for the last write to a file, but the required bookkeeping
1129  * doesn't seem worth the trouble.
1130  */
1131  pgstat_report_wait_start(WAIT_EVENT_LOGICAL_REWRITE_MAPPING_SYNC);
1132  if (pg_fsync(fd) != 0)
1135  errmsg("could not fsync file \"%s\": %m", path)));
1137 
1138  if (CloseTransientFile(fd) != 0)
1139  ereport(ERROR,
1141  errmsg("could not close file \"%s\": %m", path)));
1142 }
unsigned int uint32
Definition: c.h:506
#define PG_BINARY
Definition: c.h:1273
int errcode_for_file_access(void)
Definition: elog.c:882
int errmsg(const char *fmt,...)
Definition: elog.c:1072
#define ERROR
Definition: elog.h:39
#define ereport(elevel,...)
Definition: elog.h:149
int CloseTransientFile(int fd)
Definition: fd.c:2809
int data_sync_elevel(int elevel)
Definition: fd.c:3936
int pg_fsync(int fd)
Definition: fd.c:386
int OpenTransientFile(const char *fileName, int fileFlags)
Definition: fd.c:2633
#define MAXPGPATH
#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:470
static void pgstat_report_wait_start(uint32 wait_event_info)
Definition: wait_event.h:88
static void pgstat_report_wait_end(void)
Definition: wait_event.h:104
#define ftruncate(a, b)
Definition: win32_port.h:82
#define LSN_FORMAT_ARGS(lsn)
Definition: xlogdefs.h:43
#define XLogRecGetXid(decoder)
Definition: xlogreader.h:412

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, XLogRecGetData, and XLogRecGetXid.

Referenced by heap2_redo().

◆ HeapTupleHeaderAdvanceConflictHorizon()

void HeapTupleHeaderAdvanceConflictHorizon ( HeapTupleHeader  tuple,
TransactionId snapshotConflictHorizon 
)

Definition at line 7482 of file heapam.c.

7484 {
7485  TransactionId xmin = HeapTupleHeaderGetXmin(tuple);
7487  TransactionId xvac = HeapTupleHeaderGetXvac(tuple);
7488 
7489  if (tuple->t_infomask & HEAP_MOVED)
7490  {
7491  if (TransactionIdPrecedes(*snapshotConflictHorizon, xvac))
7492  *snapshotConflictHorizon = xvac;
7493  }
7494 
7495  /*
7496  * Ignore tuples inserted by an aborted transaction or if the tuple was
7497  * updated/deleted by the inserting transaction.
7498  *
7499  * Look for a committed hint bit, or if no xmin bit is set, check clog.
7500  */
7501  if (HeapTupleHeaderXminCommitted(tuple) ||
7503  {
7504  if (xmax != xmin &&
7505  TransactionIdFollows(xmax, *snapshotConflictHorizon))
7506  *snapshotConflictHorizon = xmax;
7507  }
7508 }
#define HeapTupleHeaderGetXvac(tup)
Definition: htup_details.h:411
#define HeapTupleHeaderGetXmin(tup)
Definition: htup_details.h:309
#define HEAP_MOVED
Definition: htup_details.h:213
#define HeapTupleHeaderXminCommitted(tup)
Definition: htup_details.h:320
#define HeapTupleHeaderGetUpdateXid(tup)
Definition: htup_details.h:361
#define HeapTupleHeaderXminInvalid(tup)
Definition: htup_details.h:325
bool TransactionIdDidCommit(TransactionId transactionId)
Definition: transam.c:126
bool TransactionIdPrecedes(TransactionId id1, TransactionId id2)
Definition: transam.c:280
bool TransactionIdFollows(TransactionId id1, TransactionId id2)
Definition: transam.c:314

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

Referenced by heap_index_delete_tuples(), heap_page_prune_and_freeze(), and heap_prune_chain().

◆ log_heap_visible()

XLogRecPtr log_heap_visible ( Relation  rel,
Buffer  heap_buffer,
Buffer  vm_buffer,
TransactionId  snapshotConflictHorizon,
uint8  vmflags 
)

Definition at line 8314 of file heapam.c.

8316 {
8317  xl_heap_visible xlrec;
8318  XLogRecPtr recptr;
8319  uint8 flags;
8320 
8321  Assert(BufferIsValid(heap_buffer));
8322  Assert(BufferIsValid(vm_buffer));
8323 
8324  xlrec.snapshotConflictHorizon = snapshotConflictHorizon;
8325  xlrec.flags = vmflags;
8328  XLogBeginInsert();
8329  XLogRegisterData((char *) &xlrec, SizeOfHeapVisible);
8330 
8331  XLogRegisterBuffer(0, vm_buffer, 0);
8332 
8333  flags = REGBUF_STANDARD;
8334  if (!XLogHintBitIsNeeded())
8335  flags |= REGBUF_NO_IMAGE;
8336  XLogRegisterBuffer(1, heap_buffer, flags);
8337 
8338  recptr = XLogInsert(RM_HEAP2_ID, XLOG_HEAP2_VISIBLE);
8339 
8340  return recptr;
8341 }
static bool BufferIsValid(Buffer bufnum)
Definition: bufmgr.h:359
#define SizeOfHeapVisible
Definition: heapam_xlog.h:445
#define RelationIsAccessibleInLogicalDecoding(relation)
Definition: rel.h:684
#define VISIBILITYMAP_XLOG_CATALOG_REL
#define XLogHintBitIsNeeded()
Definition: xlog.h:118
uint64 XLogRecPtr
Definition: xlogdefs.h:21
void XLogRegisterData(char *data, uint32 len)
Definition: xloginsert.c:364
XLogRecPtr XLogInsert(RmgrId rmid, uint8 info)
Definition: xloginsert.c:474
void XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags)
Definition: xloginsert.c:242
void XLogBeginInsert(void)
Definition: xloginsert.c:149
#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, RelationIsAccessibleInLogicalDecoding, SizeOfHeapVisible, xl_heap_visible::snapshotConflictHorizon, VISIBILITYMAP_XLOG_CATALOG_REL, XLOG_HEAP2_VISIBLE, XLogBeginInsert(), XLogHintBitIsNeeded, XLogInsert(), XLogRegisterBuffer(), and XLogRegisterData().

Referenced by visibilitymap_set().