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 "storage/sinval.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(uint16))
 
#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 XLHP_VM_ALL_VISIBLE   (1 << 8)
 
#define XLHP_VM_ALL_FROZEN   (1 << 9)
 
#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 MinSizeOfHeapInplace   (offsetof(xl_heap_inplace, nmsgs) + sizeof(int))
 
#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, uint16 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

◆ MinSizeOfHeapInplace

#define MinSizeOfHeapInplace   (offsetof(xl_heap_inplace, nmsgs) + sizeof(int))

Definition at line 444 of file heapam_xlog.h.

◆ SizeOfHeapConfirm

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

Definition at line 431 of file heapam_xlog.h.

◆ SizeOfHeapDelete

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

Definition at line 121 of file heapam_xlog.h.

◆ SizeOfHeapHeader

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

Definition at line 157 of file heapam_xlog.h.

◆ SizeOfHeapInsert

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

Definition at line 168 of file heapam_xlog.h.

◆ SizeOfHeapLock

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

Definition at line 412 of file heapam_xlog.h.

◆ SizeOfHeapLockUpdated

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

Definition at line 423 of file heapam_xlog.h.

◆ SizeOfHeapMultiInsert

#define SizeOfHeapMultiInsert   offsetof(xl_heap_multi_insert, offsets)

Definition at line 188 of file heapam_xlog.h.

◆ SizeOfHeapNewCid

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

Definition at line 478 of file heapam_xlog.h.

◆ SizeOfHeapPrune

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

Definition at line 295 of file heapam_xlog.h.

◆ SizeOfHeapTruncate

#define SizeOfHeapTruncate   (offsetof(xl_heap_truncate, relids))

Definition at line 142 of file heapam_xlog.h.

◆ SizeOfHeapUpdate

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

Definition at line 233 of file heapam_xlog.h.

◆ SizeOfHeapVisible

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

Definition at line 458 of file heapam_xlog.h.

◆ SizeOfMultiInsertTuple

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

Definition at line 199 of file heapam_xlog.h.

◆ XLH_DELETE_ALL_VISIBLE_CLEARED

#define XLH_DELETE_ALL_VISIBLE_CLEARED   (1<<0)

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

◆ XLH_DELETE_CONTAINS_OLD_KEY

#define XLH_DELETE_CONTAINS_OLD_KEY   (1<<2)

Definition at line 104 of file heapam_xlog.h.

◆ XLH_DELETE_CONTAINS_OLD_TUPLE

#define XLH_DELETE_CONTAINS_OLD_TUPLE   (1<<1)

Definition at line 103 of file heapam_xlog.h.

◆ XLH_DELETE_IS_PARTITION_MOVE

#define XLH_DELETE_IS_PARTITION_MOVE   (1<<4)

Definition at line 106 of file heapam_xlog.h.

◆ XLH_DELETE_IS_SUPER

#define XLH_DELETE_IS_SUPER   (1<<3)

Definition at line 105 of file heapam_xlog.h.

◆ XLH_FREEZE_XVAC

#define XLH_FREEZE_XVAC   0x02

Definition at line 347 of file heapam_xlog.h.

◆ XLH_INSERT_ALL_FROZEN_SET

#define XLH_INSERT_ALL_FROZEN_SET   (1<<5)

Definition at line 79 of file heapam_xlog.h.

◆ XLH_INSERT_ALL_VISIBLE_CLEARED

#define XLH_INSERT_ALL_VISIBLE_CLEARED   (1<<0)

Definition at line 72 of file heapam_xlog.h.

◆ XLH_INSERT_CONTAINS_NEW_TUPLE

#define XLH_INSERT_CONTAINS_NEW_TUPLE   (1<<3)

Definition at line 75 of file heapam_xlog.h.

◆ XLH_INSERT_IS_SPECULATIVE

#define XLH_INSERT_IS_SPECULATIVE   (1<<2)

Definition at line 74 of file heapam_xlog.h.

◆ XLH_INSERT_LAST_IN_MULTI

#define XLH_INSERT_LAST_IN_MULTI   (1<<1)

Definition at line 73 of file heapam_xlog.h.

◆ XLH_INSERT_ON_TOAST_RELATION

#define XLH_INSERT_ON_TOAST_RELATION   (1<<4)

Definition at line 76 of file heapam_xlog.h.

◆ XLH_INVALID_XVAC

#define XLH_INVALID_XVAC   0x04

Definition at line 348 of file heapam_xlog.h.

◆ XLH_LOCK_ALL_FROZEN_CLEARED

#define XLH_LOCK_ALL_FROZEN_CLEARED   0x01

Definition at line 401 of file heapam_xlog.h.

◆ XLH_TRUNCATE_CASCADE

#define XLH_TRUNCATE_CASCADE   (1<<0)

Definition at line 126 of file heapam_xlog.h.

◆ XLH_TRUNCATE_RESTART_SEQS

#define XLH_TRUNCATE_RESTART_SEQS   (1<<1)

Definition at line 127 of file heapam_xlog.h.

◆ XLH_UPDATE_CONTAINS_NEW_TUPLE

#define XLH_UPDATE_CONTAINS_NEW_TUPLE   (1<<4)

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

◆ XLH_UPDATE_CONTAINS_OLD_KEY

#define XLH_UPDATE_CONTAINS_OLD_KEY   (1<<3)

Definition at line 89 of file heapam_xlog.h.

◆ XLH_UPDATE_CONTAINS_OLD_TUPLE

#define XLH_UPDATE_CONTAINS_OLD_TUPLE   (1<<2)

Definition at line 88 of file heapam_xlog.h.

◆ XLH_UPDATE_NEW_ALL_VISIBLE_CLEARED

#define XLH_UPDATE_NEW_ALL_VISIBLE_CLEARED   (1<<1)

Definition at line 87 of file heapam_xlog.h.

◆ XLH_UPDATE_OLD_ALL_VISIBLE_CLEARED

#define XLH_UPDATE_OLD_ALL_VISIBLE_CLEARED   (1<<0)

Definition at line 85 of file heapam_xlog.h.

◆ XLH_UPDATE_PREFIX_FROM_OLD

#define XLH_UPDATE_PREFIX_FROM_OLD   (1<<5)

Definition at line 91 of file heapam_xlog.h.

◆ XLH_UPDATE_SUFFIX_FROM_OLD

#define XLH_UPDATE_SUFFIX_FROM_OLD   (1<<6)

Definition at line 92 of file heapam_xlog.h.

◆ XLHL_KEYS_UPDATED

#define XLHL_KEYS_UPDATED   0x10

Definition at line 398 of file heapam_xlog.h.

◆ XLHL_XMAX_EXCL_LOCK

#define XLHL_XMAX_EXCL_LOCK   0x04

Definition at line 396 of file heapam_xlog.h.

◆ XLHL_XMAX_IS_MULTI

#define XLHL_XMAX_IS_MULTI   0x01

Definition at line 394 of file heapam_xlog.h.

◆ XLHL_XMAX_KEYSHR_LOCK

#define XLHL_XMAX_KEYSHR_LOCK   0x08

Definition at line 397 of file heapam_xlog.h.

◆ XLHL_XMAX_LOCK_ONLY

#define XLHL_XMAX_LOCK_ONLY   0x02

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

◆ XLHP_VM_ALL_FROZEN

#define XLHP_VM_ALL_FROZEN   (1 << 9)

Definition at line 340 of file heapam_xlog.h.

◆ XLHP_VM_ALL_VISIBLE

#define XLHP_VM_ALL_VISIBLE   (1 << 8)

Definition at line 339 of file heapam_xlog.h.

◆ XLOG_HEAP2_LOCK_UPDATED

#define XLOG_HEAP2_LOCK_UPDATED   0x60

Definition at line 65 of file heapam_xlog.h.

◆ XLOG_HEAP2_MULTI_INSERT

#define XLOG_HEAP2_MULTI_INSERT   0x50

Definition at line 64 of file heapam_xlog.h.

◆ XLOG_HEAP2_NEW_CID

#define XLOG_HEAP2_NEW_CID   0x70

Definition at line 66 of file heapam_xlog.h.

◆ XLOG_HEAP2_PRUNE_ON_ACCESS

#define XLOG_HEAP2_PRUNE_ON_ACCESS   0x10

Definition at line 60 of file heapam_xlog.h.

◆ XLOG_HEAP2_PRUNE_VACUUM_CLEANUP

#define XLOG_HEAP2_PRUNE_VACUUM_CLEANUP   0x30

Definition at line 62 of file heapam_xlog.h.

◆ XLOG_HEAP2_PRUNE_VACUUM_SCAN

#define XLOG_HEAP2_PRUNE_VACUUM_SCAN   0x20

Definition at line 61 of file heapam_xlog.h.

◆ XLOG_HEAP2_REWRITE

#define XLOG_HEAP2_REWRITE   0x00

Definition at line 59 of file heapam_xlog.h.

◆ XLOG_HEAP2_VISIBLE

#define XLOG_HEAP2_VISIBLE   0x40

Definition at line 63 of file heapam_xlog.h.

◆ XLOG_HEAP_CONFIRM

#define XLOG_HEAP_CONFIRM   0x50

Definition at line 38 of file heapam_xlog.h.

◆ XLOG_HEAP_DELETE

#define XLOG_HEAP_DELETE   0x10

Definition at line 34 of file heapam_xlog.h.

◆ XLOG_HEAP_HOT_UPDATE

#define XLOG_HEAP_HOT_UPDATE   0x40

Definition at line 37 of file heapam_xlog.h.

◆ XLOG_HEAP_INIT_PAGE

#define XLOG_HEAP_INIT_PAGE   0x80

Definition at line 47 of file heapam_xlog.h.

◆ XLOG_HEAP_INPLACE

#define XLOG_HEAP_INPLACE   0x70

Definition at line 40 of file heapam_xlog.h.

◆ XLOG_HEAP_INSERT

#define XLOG_HEAP_INSERT   0x00

Definition at line 33 of file heapam_xlog.h.

◆ XLOG_HEAP_LOCK

#define XLOG_HEAP_LOCK   0x60

Definition at line 39 of file heapam_xlog.h.

◆ XLOG_HEAP_OPMASK

#define XLOG_HEAP_OPMASK   0x70

Definition at line 42 of file heapam_xlog.h.

◆ XLOG_HEAP_TRUNCATE

#define XLOG_HEAP_TRUNCATE   0x30

Definition at line 36 of file heapam_xlog.h.

◆ XLOG_HEAP_UPDATE

#define XLOG_HEAP_UPDATE   0x20

Definition at line 35 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 265 of file heapdesc.c.

266{
267 char *rec = XLogRecGetData(record);
268 uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
269
270 info &= XLOG_HEAP_OPMASK;
271 if (info == XLOG_HEAP2_PRUNE_ON_ACCESS ||
274 {
275 xl_heap_prune *xlrec = (xl_heap_prune *) rec;
276
277 if (xlrec->flags & XLHP_HAS_CONFLICT_HORIZON)
278 {
279 TransactionId conflict_xid;
280
281 memcpy(&conflict_xid, rec + SizeOfHeapPrune, sizeof(TransactionId));
282
283 appendStringInfo(buf, "snapshotConflictHorizon: %u",
284 conflict_xid);
285 }
286
287 appendStringInfo(buf, ", isCatalogRel: %c",
288 xlrec->flags & XLHP_IS_CATALOG_REL ? 'T' : 'F');
289
290 if (xlrec->flags & XLHP_VM_ALL_VISIBLE)
291 {
293
294 if (xlrec->flags & XLHP_VM_ALL_FROZEN)
295 vmflags |= VISIBILITYMAP_ALL_FROZEN;
296 appendStringInfo(buf, ", vm_flags: 0x%02X", vmflags);
297 }
298
299 if (XLogRecHasBlockData(record, 0))
300 {
301 Size datalen;
302 OffsetNumber *redirected;
303 OffsetNumber *nowdead;
304 OffsetNumber *nowunused;
305 int nredirected;
306 int nunused;
307 int ndead;
308 int nplans;
309 xlhp_freeze_plan *plans;
310 OffsetNumber *frz_offsets;
311
312 char *cursor = XLogRecGetBlockData(record, 0, &datalen);
313
315 &nplans, &plans, &frz_offsets,
316 &nredirected, &redirected,
317 &ndead, &nowdead,
318 &nunused, &nowunused);
319
320 appendStringInfo(buf, ", nplans: %u, nredirected: %u, ndead: %u, nunused: %u",
321 nplans, nredirected, ndead, nunused);
322
323 if (nplans > 0)
324 {
325 appendStringInfoString(buf, ", plans:");
326 array_desc(buf, plans, sizeof(xlhp_freeze_plan), nplans,
327 &plan_elem_desc, &frz_offsets);
328 }
329
330 if (nredirected > 0)
331 {
332 appendStringInfoString(buf, ", redirected:");
333 array_desc(buf, redirected, sizeof(OffsetNumber) * 2,
334 nredirected, &redirect_elem_desc, NULL);
335 }
336
337 if (ndead > 0)
338 {
339 appendStringInfoString(buf, ", dead:");
340 array_desc(buf, nowdead, sizeof(OffsetNumber), ndead,
341 &offset_elem_desc, NULL);
342 }
343
344 if (nunused > 0)
345 {
346 appendStringInfoString(buf, ", unused:");
347 array_desc(buf, nowunused, sizeof(OffsetNumber), nunused,
348 &offset_elem_desc, NULL);
349 }
350 }
351 }
352 else if (info == XLOG_HEAP2_VISIBLE)
353 {
354 xl_heap_visible *xlrec = (xl_heap_visible *) rec;
355
356 appendStringInfo(buf, "snapshotConflictHorizon: %u, flags: 0x%02X",
357 xlrec->snapshotConflictHorizon, xlrec->flags);
358 }
359 else if (info == XLOG_HEAP2_MULTI_INSERT)
360 {
362 bool isinit = (XLogRecGetInfo(record) & XLOG_HEAP_INIT_PAGE) != 0;
363
364 appendStringInfo(buf, "ntuples: %d, flags: 0x%02X", xlrec->ntuples,
365 xlrec->flags);
366
367 if (xlrec->flags & XLH_INSERT_ALL_FROZEN_SET)
368 appendStringInfo(buf, ", vm_flags: 0x%02X",
371
372 if (XLogRecHasBlockData(record, 0) && !isinit)
373 {
374 appendStringInfoString(buf, ", offsets:");
375 array_desc(buf, xlrec->offsets, sizeof(OffsetNumber),
376 xlrec->ntuples, &offset_elem_desc, NULL);
377 }
378 }
379 else if (info == XLOG_HEAP2_LOCK_UPDATED)
380 {
382
383 appendStringInfo(buf, "xmax: %u, off: %u, ",
384 xlrec->xmax, xlrec->offnum);
385 infobits_desc(buf, xlrec->infobits_set, "infobits");
386 appendStringInfo(buf, ", flags: 0x%02X", xlrec->flags);
387 }
388 else if (info == XLOG_HEAP2_NEW_CID)
389 {
390 xl_heap_new_cid *xlrec = (xl_heap_new_cid *) rec;
391
392 appendStringInfo(buf, "rel: %u/%u/%u, tid: %u/%u",
393 xlrec->target_locator.spcOid,
394 xlrec->target_locator.dbOid,
398 appendStringInfo(buf, ", cmin: %u, cmax: %u, combo: %u",
399 xlrec->cmin, xlrec->cmax, xlrec->combocid);
400 }
401}
uint8_t uint8
Definition: c.h:539
uint32 TransactionId
Definition: c.h:660
size_t Size
Definition: c.h:613
#define XLOG_HEAP2_MULTI_INSERT
Definition: heapam_xlog.h:64
#define XLHP_HAS_CONFLICT_HORIZON
Definition: heapam_xlog.h:316
#define XLHP_VM_ALL_VISIBLE
Definition: heapam_xlog.h:339
#define XLH_INSERT_ALL_FROZEN_SET
Definition: heapam_xlog.h:79
#define XLOG_HEAP_OPMASK
Definition: heapam_xlog.h:42
#define SizeOfHeapPrune
Definition: heapam_xlog.h:295
#define XLHP_VM_ALL_FROZEN
Definition: heapam_xlog.h:340
#define XLOG_HEAP2_PRUNE_VACUUM_SCAN
Definition: heapam_xlog.h:61
#define XLOG_HEAP2_LOCK_UPDATED
Definition: heapam_xlog.h:65
#define XLOG_HEAP2_PRUNE_ON_ACCESS
Definition: heapam_xlog.h:60
#define XLOG_HEAP2_NEW_CID
Definition: heapam_xlog.h:66
#define XLOG_HEAP2_PRUNE_VACUUM_CLEANUP
Definition: heapam_xlog.h:62
#define XLOG_HEAP2_VISIBLE
Definition: heapam_xlog.h:63
#define XLHP_IS_CATALOG_REL
Definition: heapam_xlog.h:298
#define XLOG_HEAP_INIT_PAGE
Definition: heapam_xlog.h:47
void heap_xlog_deserialize_prune_and_freeze(char *cursor, uint16 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:106
static void plan_elem_desc(StringInfo buf, void *plan, void *data)
Definition: heapdesc.c:77
static void infobits_desc(StringInfo buf, uint8 infobits, const char *keyname)
Definition: heapdesc.c:27
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:72
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:145
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:230
RelFileNumber relNumber
Definition: type.h:138
TransactionId xmax
Definition: heapam_xlog.h:417
OffsetNumber offnum
Definition: heapam_xlog.h:418
OffsetNumber offsets[FLEXIBLE_ARRAY_MEMBER]
Definition: heapam_xlog.h:185
CommandId cmin
Definition: heapam_xlog.h:467
CommandId combocid
Definition: heapam_xlog.h:469
ItemPointerData target_tid
Definition: heapam_xlog.h:475
CommandId cmax
Definition: heapam_xlog.h:468
RelFileLocator target_locator
Definition: heapam_xlog.h:474
TransactionId snapshotConflictHorizon
Definition: heapam_xlog.h:454
#define VISIBILITYMAP_ALL_FROZEN
#define VISIBILITYMAP_ALL_VISIBLE
char * XLogRecGetBlockData(XLogReaderState *record, uint8 block_id, Size *len)
Definition: xlogreader.c:2045
#define XLogRecHasBlockData(decoder, block_id)
Definition: xlogreader.h:426
#define XLogRecGetInfo(decoder)
Definition: xlogreader.h:409
#define XLogRecGetData(decoder)
Definition: xlogreader.h:414

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, VISIBILITYMAP_ALL_FROZEN, VISIBILITYMAP_ALL_VISIBLE, XLH_INSERT_ALL_FROZEN_SET, XLHP_HAS_CONFLICT_HORIZON, XLHP_IS_CATALOG_REL, XLHP_VM_ALL_FROZEN, XLHP_VM_ALL_VISIBLE, 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, and xl_heap_lock_updated::xmax.

◆ heap2_identify()

const char * heap2_identify ( uint8  info)

Definition at line 449 of file heapdesc.c.

450{
451 const char *id = NULL;
452
453 switch (info & ~XLR_INFO_MASK)
454 {
456 id = "PRUNE_ON_ACCESS";
457 break;
459 id = "PRUNE_VACUUM_SCAN";
460 break;
462 id = "PRUNE_VACUUM_CLEANUP";
463 break;
465 id = "VISIBLE";
466 break;
468 id = "MULTI_INSERT";
469 break;
471 id = "MULTI_INSERT+INIT";
472 break;
474 id = "LOCK_UPDATED";
475 break;
477 id = "NEW_CID";
478 break;
480 id = "REWRITE";
481 break;
482 }
483
484 return id;
485}
#define XLOG_HEAP2_REWRITE
Definition: heapam_xlog.h:59
#define XLR_INFO_MASK
Definition: xlogrecord.h:62

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 1346 of file heapam_xlog.c.

1347{
1348 uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
1349
1350 switch (info & XLOG_HEAP_OPMASK)
1351 {
1355 heap_xlog_prune_freeze(record);
1356 break;
1357 case XLOG_HEAP2_VISIBLE:
1358 heap_xlog_visible(record);
1359 break;
1361 heap_xlog_multi_insert(record);
1362 break;
1364 heap_xlog_lock_updated(record);
1365 break;
1366 case XLOG_HEAP2_NEW_CID:
1367
1368 /*
1369 * Nothing to do on a real replay, only used during logical
1370 * decoding.
1371 */
1372 break;
1373 case XLOG_HEAP2_REWRITE:
1375 break;
1376 default:
1377 elog(PANIC, "heap2_redo: unknown op code %u", info);
1378 }
1379}
#define PANIC
Definition: elog.h:42
#define elog(elevel,...)
Definition: elog.h:226
static void heap_xlog_prune_freeze(XLogReaderState *record)
Definition: heapam_xlog.c:30
static void heap_xlog_lock_updated(XLogReaderState *record)
Definition: heapam_xlog.c:1190
static void heap_xlog_multi_insert(XLogReaderState *record)
Definition: heapam_xlog.c:607
static void heap_xlog_visible(XLogReaderState *record)
Definition: heapam_xlog.c:255
void heap_xlog_logical_rewrite(XLogReaderState *r)
Definition: rewriteheap.c:1072

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, and XLogRecGetInfo.

◆ heap_desc()

void heap_desc ( StringInfo  buf,
XLogReaderState record 
)

Definition at line 185 of file heapdesc.c.

186{
187 char *rec = XLogRecGetData(record);
188 uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
189
190 info &= XLOG_HEAP_OPMASK;
191 if (info == XLOG_HEAP_INSERT)
192 {
193 xl_heap_insert *xlrec = (xl_heap_insert *) rec;
194
195 appendStringInfo(buf, "off: %u, flags: 0x%02X",
196 xlrec->offnum,
197 xlrec->flags);
198 }
199 else if (info == XLOG_HEAP_DELETE)
200 {
201 xl_heap_delete *xlrec = (xl_heap_delete *) rec;
202
203 appendStringInfo(buf, "xmax: %u, off: %u, ",
204 xlrec->xmax, xlrec->offnum);
205 infobits_desc(buf, xlrec->infobits_set, "infobits");
206 appendStringInfo(buf, ", flags: 0x%02X", xlrec->flags);
207 }
208 else if (info == XLOG_HEAP_UPDATE)
209 {
210 xl_heap_update *xlrec = (xl_heap_update *) rec;
211
212 appendStringInfo(buf, "old_xmax: %u, old_off: %u, ",
213 xlrec->old_xmax, xlrec->old_offnum);
214 infobits_desc(buf, xlrec->old_infobits_set, "old_infobits");
215 appendStringInfo(buf, ", flags: 0x%02X, new_xmax: %u, new_off: %u",
216 xlrec->flags, xlrec->new_xmax, xlrec->new_offnum);
217 }
218 else if (info == XLOG_HEAP_HOT_UPDATE)
219 {
220 xl_heap_update *xlrec = (xl_heap_update *) rec;
221
222 appendStringInfo(buf, "old_xmax: %u, old_off: %u, ",
223 xlrec->old_xmax, xlrec->old_offnum);
224 infobits_desc(buf, xlrec->old_infobits_set, "old_infobits");
225 appendStringInfo(buf, ", flags: 0x%02X, new_xmax: %u, new_off: %u",
226 xlrec->flags, xlrec->new_xmax, xlrec->new_offnum);
227 }
228 else if (info == XLOG_HEAP_TRUNCATE)
229 {
230 xl_heap_truncate *xlrec = (xl_heap_truncate *) rec;
231
233 appendStringInfo(buf, ", nrelids: %u", xlrec->nrelids);
234 appendStringInfoString(buf, ", relids:");
235 array_desc(buf, xlrec->relids, sizeof(Oid), xlrec->nrelids,
236 &oid_elem_desc, NULL);
237 }
238 else if (info == XLOG_HEAP_CONFIRM)
239 {
240 xl_heap_confirm *xlrec = (xl_heap_confirm *) rec;
241
242 appendStringInfo(buf, "off: %u", xlrec->offnum);
243 }
244 else if (info == XLOG_HEAP_LOCK)
245 {
246 xl_heap_lock *xlrec = (xl_heap_lock *) rec;
247
248 appendStringInfo(buf, "xmax: %u, off: %u, ",
249 xlrec->xmax, xlrec->offnum);
250 infobits_desc(buf, xlrec->infobits_set, "infobits");
251 appendStringInfo(buf, ", flags: 0x%02X", xlrec->flags);
252 }
253 else if (info == XLOG_HEAP_INPLACE)
254 {
255 xl_heap_inplace *xlrec = (xl_heap_inplace *) rec;
256
257 appendStringInfo(buf, "off: %u", xlrec->offnum);
259 xlrec->dbId, xlrec->tsId,
260 xlrec->relcacheInitFileInval);
261 }
262}
#define XLOG_HEAP_HOT_UPDATE
Definition: heapam_xlog.h:37
#define XLOG_HEAP_DELETE
Definition: heapam_xlog.h:34
#define XLOG_HEAP_TRUNCATE
Definition: heapam_xlog.h:36
#define XLOG_HEAP_UPDATE
Definition: heapam_xlog.h:35
#define XLOG_HEAP_INPLACE
Definition: heapam_xlog.h:40
#define XLOG_HEAP_LOCK
Definition: heapam_xlog.h:39
#define XLOG_HEAP_INSERT
Definition: heapam_xlog.h:33
#define XLOG_HEAP_CONFIRM
Definition: heapam_xlog.h:38
static void truncate_flags_desc(StringInfo buf, uint8 flags)
Definition: heapdesc.c:56
unsigned int Oid
Definition: postgres_ext.h:32
void oid_elem_desc(StringInfo buf, void *relid, void *data)
void standby_desc_invalidations(StringInfo buf, int nmsgs, SharedInvalidationMessage *msgs, Oid dbId, Oid tsId, bool relcacheInitFileInval)
Definition: standbydesc.c:101
OffsetNumber offnum
Definition: heapam_xlog.h:428
TransactionId xmax
Definition: heapam_xlog.h:115
OffsetNumber offnum
Definition: heapam_xlog.h:116
uint8 infobits_set
Definition: heapam_xlog.h:117
OffsetNumber offnum
Definition: heapam_xlog.h:436
SharedInvalidationMessage msgs[FLEXIBLE_ARRAY_MEMBER]
Definition: heapam_xlog.h:441
bool relcacheInitFileInval
Definition: heapam_xlog.h:439
OffsetNumber offnum
Definition: heapam_xlog.h:162
uint8 infobits_set
Definition: heapam_xlog.h:408
OffsetNumber offnum
Definition: heapam_xlog.h:407
TransactionId xmax
Definition: heapam_xlog.h:406
Oid relids[FLEXIBLE_ARRAY_MEMBER]
Definition: heapam_xlog.h:139
TransactionId new_xmax
Definition: heapam_xlog.h:224
uint8 old_infobits_set
Definition: heapam_xlog.h:222
TransactionId old_xmax
Definition: heapam_xlog.h:220
OffsetNumber old_offnum
Definition: heapam_xlog.h:221
OffsetNumber new_offnum
Definition: heapam_xlog.h:225

References appendStringInfo(), appendStringInfoString(), array_desc(), buf, xl_heap_inplace::dbId, 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_inplace::msgs, xl_heap_update::new_offnum, xl_heap_update::new_xmax, xl_heap_inplace::nmsgs, 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_inplace::relcacheInitFileInval, xl_heap_truncate::relids, standby_desc_invalidations(), truncate_flags_desc(), xl_heap_inplace::tsId, 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, xl_heap_delete::xmax, and xl_heap_lock::xmax.

◆ heap_identify()

const char * heap_identify ( uint8  info)

Definition at line 404 of file heapdesc.c.

405{
406 const char *id = NULL;
407
408 switch (info & ~XLR_INFO_MASK)
409 {
410 case XLOG_HEAP_INSERT:
411 id = "INSERT";
412 break;
414 id = "INSERT+INIT";
415 break;
416 case XLOG_HEAP_DELETE:
417 id = "DELETE";
418 break;
419 case XLOG_HEAP_UPDATE:
420 id = "UPDATE";
421 break;
423 id = "UPDATE+INIT";
424 break;
426 id = "HOT_UPDATE";
427 break;
429 id = "HOT_UPDATE+INIT";
430 break;
432 id = "TRUNCATE";
433 break;
435 id = "HEAP_CONFIRM";
436 break;
437 case XLOG_HEAP_LOCK:
438 id = "LOCK";
439 break;
441 id = "INPLACE";
442 break;
443 }
444
445 return id;
446}

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 1385 of file heapam_xlog.c.

1386{
1387 Page page = (Page) pagedata;
1388 OffsetNumber off;
1389
1391
1392 mask_page_hint_bits(page);
1393 mask_unused_space(page);
1394
1395 for (off = 1; off <= PageGetMaxOffsetNumber(page); off++)
1396 {
1397 ItemId iid = PageGetItemId(page, off);
1398 char *page_item;
1399
1400 page_item = (char *) (page + ItemIdGetOffset(iid));
1401
1402 if (ItemIdIsNormal(iid))
1403 {
1404 HeapTupleHeader page_htup = (HeapTupleHeader) page_item;
1405
1406 /*
1407 * If xmin of a tuple is not yet frozen, we should ignore
1408 * differences in hint bits, since they can be set without
1409 * emitting WAL.
1410 */
1411 if (!HeapTupleHeaderXminFrozen(page_htup))
1412 page_htup->t_infomask &= ~HEAP_XACT_MASK;
1413 else
1414 {
1415 /* Still we need to mask xmax hint bits. */
1416 page_htup->t_infomask &= ~HEAP_XMAX_INVALID;
1417 page_htup->t_infomask &= ~HEAP_XMAX_COMMITTED;
1418 }
1419
1420 /*
1421 * During replay, we set Command Id to FirstCommandId. Hence, mask
1422 * it. See heap_xlog_insert() for details.
1423 */
1425
1426 /*
1427 * For a speculative tuple, heap_insert() does not set ctid in the
1428 * caller-passed heap tuple itself, leaving the ctid field to
1429 * contain a speculative token value - a per-backend monotonically
1430 * increasing identifier. Besides, it does not WAL-log ctid under
1431 * any circumstances.
1432 *
1433 * During redo, heap_xlog_insert() sets t_ctid to current block
1434 * number and self offset number. It doesn't care about any
1435 * speculative insertions on the primary. Hence, we set t_ctid to
1436 * current block number and self offset number to ignore any
1437 * inconsistency.
1438 */
1439 if (HeapTupleHeaderIsSpeculative(page_htup))
1440 ItemPointerSet(&page_htup->t_ctid, blkno, off);
1441
1442 /*
1443 * NB: Not ignoring ctid changes due to the tuple having moved
1444 * (i.e. HeapTupleHeaderIndicatesMovedPartitions), because that's
1445 * important information that needs to be in-sync between primary
1446 * and standby, and thus is WAL logged.
1447 */
1448 }
1449
1450 /*
1451 * Ignore any padding bytes after the tuple, when the length of the
1452 * item is not MAXALIGNed.
1453 */
1454 if (ItemIdHasStorage(iid))
1455 {
1456 int len = ItemIdGetLength(iid);
1457 int padlen = MAXALIGN(len) - len;
1458
1459 if (padlen > 0)
1460 memset(page_item + len, MASK_MARKER, padlen);
1461 }
1462 }
1463}
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
static ItemId PageGetItemId(Page page, OffsetNumber offsetNumber)
Definition: bufpage.h:243
PageData * Page
Definition: bufpage.h:81
static OffsetNumber PageGetMaxOffsetNumber(const PageData *page)
Definition: bufpage.h:371
#define MAXALIGN(LEN)
Definition: c.h:813
HeapTupleHeaderData * HeapTupleHeader
Definition: htup.h:23
static bool HeapTupleHeaderXminFrozen(const HeapTupleHeaderData *tup)
Definition: htup_details.h:350
#define HEAP_XMAX_COMMITTED
Definition: htup_details.h:207
#define HEAP_XACT_MASK
Definition: htup_details.h:215
#define HEAP_XMAX_INVALID
Definition: htup_details.h:208
static bool HeapTupleHeaderIsSpeculative(const HeapTupleHeaderData *tup)
Definition: htup_details.h:461
#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::@48 t_field3
CommandId t_cid
Definition: htup_details.h:129
union HeapTupleHeaderData::@49 t_choice
ItemPointerData t_ctid
Definition: htup_details.h:161
HeapTupleFields t_heap
Definition: htup_details.h:157

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 1300 of file heapam_xlog.c.

1301{
1302 uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
1303
1304 /*
1305 * These operations don't overwrite MVCC data so no conflict processing is
1306 * required. The ones in heap2 rmgr do.
1307 */
1308
1309 switch (info & XLOG_HEAP_OPMASK)
1310 {
1311 case XLOG_HEAP_INSERT:
1312 heap_xlog_insert(record);
1313 break;
1314 case XLOG_HEAP_DELETE:
1315 heap_xlog_delete(record);
1316 break;
1317 case XLOG_HEAP_UPDATE:
1318 heap_xlog_update(record, false);
1319 break;
1320 case XLOG_HEAP_TRUNCATE:
1321
1322 /*
1323 * TRUNCATE is a no-op because the actions are already logged as
1324 * SMGR WAL records. TRUNCATE WAL record only exists for logical
1325 * decoding.
1326 */
1327 break;
1329 heap_xlog_update(record, true);
1330 break;
1331 case XLOG_HEAP_CONFIRM:
1332 heap_xlog_confirm(record);
1333 break;
1334 case XLOG_HEAP_LOCK:
1335 heap_xlog_lock(record);
1336 break;
1337 case XLOG_HEAP_INPLACE:
1338 heap_xlog_inplace(record);
1339 break;
1340 default:
1341 elog(PANIC, "heap_redo: unknown op code %u", info);
1342 }
1343}
static void heap_xlog_insert(XLogReaderState *record)
Definition: heapam_xlog.c:489
static void heap_xlog_update(XLogReaderState *record, bool hot_update)
Definition: heapam_xlog.c:802
static void heap_xlog_delete(XLogReaderState *record)
Definition: heapam_xlog.c:413
static void heap_xlog_lock(XLogReaderState *record)
Definition: heapam_xlog.c:1116
static void heap_xlog_inplace(XLogReaderState *record)
Definition: heapam_xlog.c:1253
static void heap_xlog_confirm(XLogReaderState *record)
Definition: heapam_xlog.c:1077

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, and XLogRecGetInfo.

◆ heap_xlog_deserialize_prune_and_freeze()

void heap_xlog_deserialize_prune_and_freeze ( char *  cursor,
uint16  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 106 of file heapdesc.c.

112{
113 if (flags & XLHP_HAS_FREEZE_PLANS)
114 {
115 xlhp_freeze_plans *freeze_plans = (xlhp_freeze_plans *) cursor;
116
117 *nplans = freeze_plans->nplans;
118 Assert(*nplans > 0);
119 *plans = freeze_plans->plans;
120
121 cursor += offsetof(xlhp_freeze_plans, plans);
122 cursor += sizeof(xlhp_freeze_plan) * *nplans;
123 }
124 else
125 {
126 *nplans = 0;
127 *plans = NULL;
128 }
129
130 if (flags & XLHP_HAS_REDIRECTIONS)
131 {
133
134 *nredirected = subrecord->ntargets;
135 Assert(*nredirected > 0);
136 *redirected = &subrecord->data[0];
137
138 cursor += offsetof(xlhp_prune_items, data);
139 cursor += sizeof(OffsetNumber[2]) * *nredirected;
140 }
141 else
142 {
143 *nredirected = 0;
144 *redirected = NULL;
145 }
146
147 if (flags & XLHP_HAS_DEAD_ITEMS)
148 {
150
151 *ndead = subrecord->ntargets;
152 Assert(*ndead > 0);
153 *nowdead = subrecord->data;
154
155 cursor += offsetof(xlhp_prune_items, data);
156 cursor += sizeof(OffsetNumber) * *ndead;
157 }
158 else
159 {
160 *ndead = 0;
161 *nowdead = NULL;
162 }
163
164 if (flags & XLHP_HAS_NOW_UNUSED_ITEMS)
165 {
167
168 *nunused = subrecord->ntargets;
169 Assert(*nunused > 0);
170 *nowunused = subrecord->data;
171
172 cursor += offsetof(xlhp_prune_items, data);
173 cursor += sizeof(OffsetNumber) * *nunused;
174 }
175 else
176 {
177 *nunused = 0;
178 *nowunused = NULL;
179 }
180
181 *frz_offsets = (OffsetNumber *) cursor;
182}
Assert(PointerIsAligned(start, uint64))
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:376
OffsetNumber data[FLEXIBLE_ARRAY_MEMBER]
Definition: heapam_xlog.h:389

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 1072 of file rewriteheap.c.

1073{
1074 char path[MAXPGPATH];
1075 int fd;
1077 uint32 len;
1078 char *data;
1079
1081
1082 snprintf(path, MAXPGPATH,
1085 LSN_FORMAT_ARGS(xlrec->start_lsn),
1086 xlrec->mapped_xid, XLogRecGetXid(r));
1087
1088 fd = OpenTransientFile(path,
1089 O_CREAT | O_WRONLY | PG_BINARY);
1090 if (fd < 0)
1091 ereport(ERROR,
1093 errmsg("could not create file \"%s\": %m", path)));
1094
1095 /*
1096 * Truncate all data that's not guaranteed to have been safely fsynced (by
1097 * previous record or by the last checkpoint).
1098 */
1099 pgstat_report_wait_start(WAIT_EVENT_LOGICAL_REWRITE_TRUNCATE);
1100 if (ftruncate(fd, xlrec->offset) != 0)
1101 ereport(ERROR,
1103 errmsg("could not truncate file \"%s\" to %u: %m",
1104 path, (uint32) xlrec->offset)));
1106
1107 data = XLogRecGetData(r) + sizeof(*xlrec);
1108
1109 len = xlrec->num_mappings * sizeof(LogicalRewriteMappingData);
1110
1111 /* write out tail end of mapping file (again) */
1112 errno = 0;
1113 pgstat_report_wait_start(WAIT_EVENT_LOGICAL_REWRITE_MAPPING_WRITE);
1114 if (pg_pwrite(fd, data, len, xlrec->offset) != len)
1115 {
1116 /* if write didn't set errno, assume problem is no disk space */
1117 if (errno == 0)
1118 errno = ENOSPC;
1119 ereport(ERROR,
1121 errmsg("could not write to file \"%s\": %m", path)));
1122 }
1124
1125 /*
1126 * Now fsync all previously written data. We could improve things and only
1127 * do this for the last write to a file, but the required bookkeeping
1128 * doesn't seem worth the trouble.
1129 */
1130 pgstat_report_wait_start(WAIT_EVENT_LOGICAL_REWRITE_MAPPING_SYNC);
1131 if (pg_fsync(fd) != 0)
1134 errmsg("could not fsync file \"%s\": %m", path)));
1136
1137 if (CloseTransientFile(fd) != 0)
1138 ereport(ERROR,
1140 errmsg("could not close file \"%s\": %m", path)));
1141}
#define PG_BINARY
Definition: c.h:1261
uint32_t uint32
Definition: c.h:541
int errcode_for_file_access(void)
Definition: elog.c:886
int errmsg(const char *fmt,...)
Definition: elog.c:1080
#define ERROR
Definition: elog.h:39
#define ereport(elevel,...)
Definition: elog.h:150
int CloseTransientFile(int fd)
Definition: fd.c:2868
int data_sync_elevel(int elevel)
Definition: fd.c:3998
int pg_fsync(int fd)
Definition: fd.c:386
int OpenTransientFile(const char *fileName, int fileFlags)
Definition: fd.c:2691
#define MAXPGPATH
#define pg_pwrite
Definition: port.h:248
#define snprintf
Definition: port.h:260
static int fd(const char *x, int i)
Definition: preproc-init.c:105
#define PG_LOGICAL_MAPPINGS_DIR
Definition: reorderbuffer.h:23
#define LOGICAL_REWRITE_FORMAT
Definition: rewriteheap.h:54
struct LogicalRewriteMappingData LogicalRewriteMappingData
TransactionId mapped_xid
Definition: heapam_xlog.h:483
static void pgstat_report_wait_start(uint32 wait_event_info)
Definition: wait_event.h:69
static void pgstat_report_wait_end(void)
Definition: wait_event.h:85
#define LSN_FORMAT_ARGS(lsn)
Definition: xlogdefs.h:47
#define XLogRecGetXid(decoder)
Definition: xlogreader.h:411

References CloseTransientFile(), data, data_sync_elevel(), ereport, errcode_for_file_access(), errmsg(), ERROR, fd(), 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_LOGICAL_MAPPINGS_DIR, 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 7999 of file heapam.c.

8001{
8005
8006 if (tuple->t_infomask & HEAP_MOVED)
8007 {
8008 if (TransactionIdPrecedes(*snapshotConflictHorizon, xvac))
8009 *snapshotConflictHorizon = xvac;
8010 }
8011
8012 /*
8013 * Ignore tuples inserted by an aborted transaction or if the tuple was
8014 * updated/deleted by the inserting transaction.
8015 *
8016 * Look for a committed hint bit, or if no xmin bit is set, check clog.
8017 */
8018 if (HeapTupleHeaderXminCommitted(tuple) ||
8020 {
8021 if (xmax != xmin &&
8022 TransactionIdFollows(xmax, *snapshotConflictHorizon))
8023 *snapshotConflictHorizon = xmax;
8024 }
8025}
static bool HeapTupleHeaderXminInvalid(const HeapTupleHeaderData *tup)
Definition: htup_details.h:343
static TransactionId HeapTupleHeaderGetXvac(const HeapTupleHeaderData *tup)
Definition: htup_details.h:442
#define HEAP_MOVED
Definition: htup_details.h:213
static TransactionId HeapTupleHeaderGetXmin(const HeapTupleHeaderData *tup)
Definition: htup_details.h:324
static TransactionId HeapTupleHeaderGetUpdateXid(const HeapTupleHeaderData *tup)
Definition: htup_details.h:397
static bool HeapTupleHeaderXminCommitted(const HeapTupleHeaderData *tup)
Definition: htup_details.h:337
bool TransactionIdDidCommit(TransactionId transactionId)
Definition: transam.c:126
static bool TransactionIdFollows(TransactionId id1, TransactionId id2)
Definition: transam.h:297
static bool TransactionIdPrecedes(TransactionId id1, TransactionId id2)
Definition: transam.h:263

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

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

◆ log_heap_visible()

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

Definition at line 8830 of file heapam.c.

8832{
8833 xl_heap_visible xlrec;
8834 XLogRecPtr recptr;
8835 uint8 flags;
8836
8837 Assert(BufferIsValid(heap_buffer));
8838 Assert(BufferIsValid(vm_buffer));
8839
8840 xlrec.snapshotConflictHorizon = snapshotConflictHorizon;
8841 xlrec.flags = vmflags;
8846
8847 XLogRegisterBuffer(0, vm_buffer, 0);
8848
8849 flags = REGBUF_STANDARD;
8850 if (!XLogHintBitIsNeeded())
8851 flags |= REGBUF_NO_IMAGE;
8852 XLogRegisterBuffer(1, heap_buffer, flags);
8853
8854 recptr = XLogInsert(RM_HEAP2_ID, XLOG_HEAP2_VISIBLE);
8855
8856 return recptr;
8857}
static bool BufferIsValid(Buffer bufnum)
Definition: bufmgr.h:387
#define SizeOfHeapVisible
Definition: heapam_xlog.h:458
#define RelationIsAccessibleInLogicalDecoding(relation)
Definition: rel.h:694
#define VISIBILITYMAP_XLOG_CATALOG_REL
#define XLogHintBitIsNeeded()
Definition: xlog.h:120
uint64 XLogRecPtr
Definition: xlogdefs.h:21
XLogRecPtr XLogInsert(RmgrId rmid, uint8 info)
Definition: xloginsert.c:478
void XLogRegisterData(const void *data, uint32 len)
Definition: xloginsert.c:368
void XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags)
Definition: xloginsert.c:245
void XLogBeginInsert(void)
Definition: xloginsert.c:152
#define REGBUF_STANDARD
Definition: xloginsert.h:35
#define REGBUF_NO_IMAGE
Definition: xloginsert.h:33

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