PostgreSQL Source Code git master
Loading...
Searching...
No Matches
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_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_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_NO_LOGICAL   (1<<5)
 
#define XLH_DELETE_CONTAINS_OLD    (XLH_DELETE_CONTAINS_OLD_TUPLE | XLH_DELETE_CONTAINS_OLD_KEY)
 
#define HEAP_DELETE_BLKREF_HEAP   0
 
#define HEAP_DELETE_BLKREF_VM   1
 
#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 HEAP_INSERT_BLKREF_HEAP   0
 
#define HEAP_INSERT_BLKREF_VM   1
 
#define SizeOfHeapInsert   (offsetof(xl_heap_insert, flags) + sizeof(uint8))
 
#define HEAP_MULTI_INSERT_BLKREF_HEAP   0
 
#define HEAP_MULTI_INSERT_BLKREF_VM   1
 
#define SizeOfHeapMultiInsert   offsetof(xl_heap_multi_insert, offsets)
 
#define SizeOfMultiInsertTuple   (offsetof(xl_multi_insert_tuple, t_hoff) + sizeof(uint8))
 
#define HEAP_UPDATE_BLKREF_HEAP_NEW   0
 
#define HEAP_UPDATE_BLKREF_HEAP_OLD   1
 
#define HEAP_UPDATE_BLKREF_VM_NEW   2
 
#define HEAP_UPDATE_BLKREF_VM_OLD   3
 
#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 HEAP_LOCK_BLKREF_HEAP   0
 
#define HEAP_LOCK_BLKREF_VM   1
 
#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 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_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 charheap_identify (uint8 info)
 
void heap_mask (char *pagedata, BlockNumber blkno)
 
void heap2_redo (XLogReaderState *record)
 
void heap2_desc (StringInfo buf, XLogReaderState *record)
 
const charheap2_identify (uint8 info)
 
void heap_xlog_logical_rewrite (XLogReaderState *r)
 
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

◆ HEAP_DELETE_BLKREF_HEAP

#define HEAP_DELETE_BLKREF_HEAP   0

Definition at line 115 of file heapam_xlog.h.

◆ HEAP_DELETE_BLKREF_VM

#define HEAP_DELETE_BLKREF_VM   1

Definition at line 116 of file heapam_xlog.h.

◆ HEAP_INSERT_BLKREF_HEAP

#define HEAP_INSERT_BLKREF_HEAP   0

Definition at line 165 of file heapam_xlog.h.

◆ HEAP_INSERT_BLKREF_VM

#define HEAP_INSERT_BLKREF_VM   1

Definition at line 166 of file heapam_xlog.h.

◆ HEAP_LOCK_BLKREF_HEAP

#define HEAP_LOCK_BLKREF_HEAP   0

Definition at line 433 of file heapam_xlog.h.

◆ HEAP_LOCK_BLKREF_VM

#define HEAP_LOCK_BLKREF_VM   1

Definition at line 434 of file heapam_xlog.h.

◆ HEAP_MULTI_INSERT_BLKREF_HEAP

#define HEAP_MULTI_INSERT_BLKREF_HEAP   0

Definition at line 185 of file heapam_xlog.h.

◆ HEAP_MULTI_INSERT_BLKREF_VM

#define HEAP_MULTI_INSERT_BLKREF_VM   1

Definition at line 186 of file heapam_xlog.h.

◆ HEAP_UPDATE_BLKREF_HEAP_NEW

#define HEAP_UPDATE_BLKREF_HEAP_NEW   0

Definition at line 242 of file heapam_xlog.h.

◆ HEAP_UPDATE_BLKREF_HEAP_OLD

#define HEAP_UPDATE_BLKREF_HEAP_OLD   1

Definition at line 243 of file heapam_xlog.h.

◆ HEAP_UPDATE_BLKREF_VM_NEW

#define HEAP_UPDATE_BLKREF_VM_NEW   2

Definition at line 244 of file heapam_xlog.h.

◆ HEAP_UPDATE_BLKREF_VM_OLD

#define HEAP_UPDATE_BLKREF_VM_OLD   3

Definition at line 245 of file heapam_xlog.h.

◆ MinSizeOfHeapInplace

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

Definition at line 476 of file heapam_xlog.h.

◆ SizeOfHeapConfirm

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

Definition at line 463 of file heapam_xlog.h.

◆ SizeOfHeapDelete

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

Definition at line 126 of file heapam_xlog.h.

◆ SizeOfHeapHeader

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

Definition at line 162 of file heapam_xlog.h.

◆ SizeOfHeapInsert

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

Definition at line 176 of file heapam_xlog.h.

◆ SizeOfHeapLock

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

Definition at line 444 of file heapam_xlog.h.

◆ SizeOfHeapLockUpdated

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

Definition at line 455 of file heapam_xlog.h.

◆ SizeOfHeapMultiInsert

#define SizeOfHeapMultiInsert   offsetof(xl_heap_multi_insert, offsets)

Definition at line 200 of file heapam_xlog.h.

◆ SizeOfHeapNewCid

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

Definition at line 496 of file heapam_xlog.h.

◆ SizeOfHeapPrune

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

Definition at line 324 of file heapam_xlog.h.

◆ SizeOfHeapTruncate

#define SizeOfHeapTruncate   (offsetof(xl_heap_truncate, relids))

Definition at line 147 of file heapam_xlog.h.

◆ SizeOfHeapUpdate

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

Definition at line 262 of file heapam_xlog.h.

◆ SizeOfMultiInsertTuple

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

Definition at line 211 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

Definition at line 111 of file heapam_xlog.h.

118{
119 TransactionId xmax; /* xmax of the deleted tuple */
120 OffsetNumber offnum; /* deleted tuple's offset */
121 uint8 infobits_set; /* infomask bits */
122 uint8 flags;
124
125#define SizeOfHeapDelete (offsetof(xl_heap_delete, flags) + sizeof(uint8))
126
127/*
128 * xl_heap_truncate flag values, 8 bits are available.
129 */
130#define XLH_TRUNCATE_CASCADE (1<<0)
131#define XLH_TRUNCATE_RESTART_SEQS (1<<1)
132
133/*
134 * For truncate we list all truncated relids in an array, followed by all
135 * sequence relids that need to be restarted, if any.
136 * All rels are always within the same database, so we just list dbid once.
137 */
138typedef struct xl_heap_truncate
139{
140 Oid dbId;
142 uint8 flags;
145
146#define SizeOfHeapTruncate (offsetof(xl_heap_truncate, relids))
147
148/*
149 * We don't store the whole fixed part (HeapTupleHeaderData) of an inserted
150 * or updated tuple in WAL; we can save a few bytes by reconstructing the
151 * fields that are available elsewhere in the WAL record, or perhaps just
152 * plain needn't be reconstructed. These are the fields we must store.
153 */
154typedef struct xl_heap_header
155{
160
161#define SizeOfHeapHeader (offsetof(xl_heap_header, t_hoff) + sizeof(uint8))
162
163/* This is what we need to know about insert */
164#define HEAP_INSERT_BLKREF_HEAP 0
165#define HEAP_INSERT_BLKREF_VM 1
166
167typedef struct xl_heap_insert
168{
169 OffsetNumber offnum; /* inserted tuple's offset */
170 uint8 flags;
171
172 /* xl_heap_header & TUPLE DATA in HEAP_INSERT_BLKREF_HEAP */
174
175#define SizeOfHeapInsert (offsetof(xl_heap_insert, flags) + sizeof(uint8))
176
177/*
178 * This is what we need to know about a multi-insert.
179 *
180 * The main data of the record consists of this xl_heap_multi_insert header.
181 * 'offsets' array is omitted if the whole page is reinitialized
182 * (XLOG_HEAP_INIT_PAGE).
183 */
184#define HEAP_MULTI_INSERT_BLKREF_HEAP 0
185#define HEAP_MULTI_INSERT_BLKREF_VM 1
186
187/*
188 * In HEAP_MULTI_INSERT_BLKREF_HEAP's data portion, there is an
189 * xl_multi_insert_tuple struct, followed by the tuple data for each tuple.
190 * There is padding to align each xl_multi_insert_tuple struct.
191 */
192typedef struct xl_heap_multi_insert
193{
194 uint8 flags;
198
199#define SizeOfHeapMultiInsert offsetof(xl_heap_multi_insert, offsets)
200
201typedef struct xl_multi_insert_tuple
202{
203 uint16 datalen; /* size of tuple data that follows */
207 /* TUPLE DATA FOLLOWS AT END OF STRUCT */
209
210#define SizeOfMultiInsertTuple (offsetof(xl_multi_insert_tuple, t_hoff) + sizeof(uint8))
211
212/*
213 * This is what we need to know about update|hot_update
214 *
215 * HEAP_UPDATE_BLKREF_HEAP_NEW: new page
216 *
217 * If XLH_UPDATE_PREFIX_FROM_OLD or XLH_UPDATE_SUFFIX_FROM_OLD flags are set,
218 * the prefix and/or suffix come first, as one or two uint16s.
219 *
220 * After that, xl_heap_header and new tuple data follow. The new tuple
221 * data doesn't include the prefix and suffix, which are copied from the
222 * old tuple on replay.
223 *
224 * If XLH_UPDATE_CONTAINS_NEW_TUPLE flag is given, the tuple data is
225 * included even if a full-page image was taken.
226 *
227 * HEAP_UPDATE_BLKREF_HEAP_OLD: old page, if different. (no data, just a reference
228 * to the block)
229 *
230 * HEAP_UPDATE_BLKREF_VM_NEW: VM page covering the new heap page. Registered
231 * when XLH_UPDATE_NEW_ALL_VISIBLE_CLEARED is set and the new heap page's VM bit
232 * was actually cleared. Also covers the old heap page's VM bits when both heap
233 * pages map to the same VM page and both blocks' VM bits were actually cleared.
234 *
235 * HEAP_UPDATE_BLKREF_VM_OLD: VM page covering the old heap page. Only
236 * registered when XLH_UPDATE_OLD_ALL_VISIBLE_CLEARED is set and the old heap
237 * page's VM bits were actually cleared. Also only registered when the old heap
238 * page's VM bits are on a different VM page than the new heap page's or they
239 * are on the same VM page and only the old block's VM bits are cleared.
240 */
241#define HEAP_UPDATE_BLKREF_HEAP_NEW 0
242#define HEAP_UPDATE_BLKREF_HEAP_OLD 1
243#define HEAP_UPDATE_BLKREF_VM_NEW 2
244#define HEAP_UPDATE_BLKREF_VM_OLD 3
245
246typedef struct xl_heap_update
247{
248 TransactionId old_xmax; /* xmax of the old tuple */
249 OffsetNumber old_offnum; /* old tuple's offset */
250 uint8 old_infobits_set; /* infomask bits to set on old tuple */
251 uint8 flags;
252 TransactionId new_xmax; /* xmax of the new tuple */
253 OffsetNumber new_offnum; /* new tuple's offset */
254
255 /*
256 * If XLH_UPDATE_CONTAINS_OLD_TUPLE or XLH_UPDATE_CONTAINS_OLD_KEY flags
257 * are set, xl_heap_header and tuple data for the old tuple follow.
258 */
260
261#define SizeOfHeapUpdate (offsetof(xl_heap_update, new_offnum) + sizeof(OffsetNumber))
262
263/*
264 * These structures and flags encode VACUUM pruning and freezing and on-access
265 * pruning page modifications.
266 *
267 * xl_heap_prune is the main record. The XLHP_HAS_* flags indicate which
268 * "sub-records" are included and the other XLHP_* flags provide additional
269 * information about the conditions for replay.
270 *
271 * The data for block reference 0 contains "sub-records" depending on which of
272 * the XLHP_HAS_* flags are set. See xlhp_* struct definitions below. The
273 * sub-records appear in the same order as the XLHP_* flags. An example
274 * record with every sub-record included:
275 *
276 *-----------------------------------------------------------------------------
277 * Main data section:
278 *
279 * xl_heap_prune
280 * uint16 flags
281 * TransactionId snapshot_conflict_horizon
282 *
283 * Block 0 data section:
284 *
285 * xlhp_freeze_plans
286 * uint16 nplans
287 * [2 bytes of padding]
288 * xlhp_freeze_plan plans[nplans]
289 *
290 * xlhp_prune_items
291 * uint16 nredirected
292 * OffsetNumber redirected[2 * nredirected]
293 *
294 * xlhp_prune_items
295 * uint16 ndead
296 * OffsetNumber nowdead[ndead]
297 *
298 * xlhp_prune_items
299 * uint16 nunused
300 * OffsetNumber nowunused[nunused]
301 *
302 * OffsetNumber frz_offsets[sum([plan.ntuples for plan in plans])]
303 *-----------------------------------------------------------------------------
304 *
305 * NOTE: because the record data is assembled from many optional parts, we
306 * have to pay close attention to alignment. In the main data section,
307 * 'snapshot_conflict_horizon' is stored unaligned after 'flags', to save
308 * space. In the block 0 data section, the freeze plans appear first, because
309 * they contain TransactionId fields that require 4-byte alignment. All the
310 * other fields require only 2-byte alignment. This is also the reason that
311 * 'frz_offsets' is stored separately from the xlhp_freeze_plan structs.
312 */
313typedef struct xl_heap_prune
314{
316
317 /*
318 * If XLHP_HAS_CONFLICT_HORIZON is set, the conflict horizon XID follows,
319 * unaligned
320 */
322
323#define SizeOfHeapPrune (offsetof(xl_heap_prune, flags) + sizeof(uint16))
324
325/* to handle recovery conflict during logical decoding on standby */
326#define XLHP_IS_CATALOG_REL (1 << 1)
327
328/*
329 * Does replaying the record require a cleanup-lock?
330 *
331 * Pruning, in VACUUM's first pass or when otherwise accessing a page,
332 * requires a cleanup lock. For freezing, and VACUUM's second pass which
333 * marks LP_DEAD line pointers as unused without moving any tuple data, an
334 * ordinary exclusive lock is sufficient.
335 */
336#define XLHP_CLEANUP_LOCK (1 << 2)
337
338/*
339 * If we remove or freeze any entries that contain xids, we need to include a
340 * snapshot conflict horizon. It's used in Hot Standby mode to ensure that
341 * there are no queries running for which the removed tuples are still
342 * visible, or which still consider the frozen XIDs as running.
343 */
344#define XLHP_HAS_CONFLICT_HORIZON (1 << 3)
345
346/*
347 * Indicates that an xlhp_freeze_plans sub-record and one or more
348 * xlhp_freeze_plan sub-records are present.
349 */
350#define XLHP_HAS_FREEZE_PLANS (1 << 4)
351
352/*
353 * XLHP_HAS_REDIRECTIONS, XLHP_HAS_DEAD_ITEMS, and XLHP_HAS_NOW_UNUSED_ITEMS
354 * indicate that xlhp_prune_items sub-records with redirected, dead, and
355 * unused item offsets are present.
356 */
357#define XLHP_HAS_REDIRECTIONS (1 << 5)
358#define XLHP_HAS_DEAD_ITEMS (1 << 6)
359#define XLHP_HAS_NOW_UNUSED_ITEMS (1 << 7)
360
361/*
362 * The xl_heap_prune record's flags may also contain which VM bits to set.
363 * xl_heap_prune should always use the XLHP_VM_ALL_VISIBLE and
364 * XLHP_VM_ALL_FROZEN flags and translate them to their visibilitymapdefs.h
365 * equivalents, VISIBILITYMAP_ALL_VISIBLE and VISIBILITYMAP_ALL_FROZEN.
366 */
367#define XLHP_VM_ALL_VISIBLE (1 << 8)
368#define XLHP_VM_ALL_FROZEN (1 << 9)
369
370/*
371 * xlhp_freeze_plan describes how to freeze a group of one or more heap tuples
372 * (appears in xl_heap_prune's xlhp_freeze_plans sub-record)
373 */
374/* 0x01 was XLH_FREEZE_XMIN */
375#define XLH_FREEZE_XVAC 0x02
376#define XLH_INVALID_XVAC 0x04
377
378typedef struct xlhp_freeze_plan
379{
384
385 /* Length of individual page offset numbers array for this plan */
388
389/*
390 * This is what we need to know about a block being frozen during vacuum
391 *
392 * The backup block's data contains an array of xlhp_freeze_plan structs (with
393 * nplans elements). The individual item offsets are located in an array at
394 * the end of the entire record with nplans * (each plan's ntuples) members
395 * Those offsets are in the same order as the plans. The REDO routine uses
396 * the offsets to freeze the corresponding heap tuples.
397 *
398 * (As of PostgreSQL 17, XLOG_HEAP2_PRUNE_VACUUM_SCAN records replace the
399 * separate XLOG_HEAP2_FREEZE_PAGE records.)
400 */
401typedef struct xlhp_freeze_plans
402{
406
407/*
408 * Generic sub-record type contained in block reference 0 of an xl_heap_prune
409 * record and used for redirect, dead, and unused items if any of
410 * XLHP_HAS_REDIRECTIONS/XLHP_HAS_DEAD_ITEMS/XLHP_HAS_NOW_UNUSED_ITEMS are
411 * set. Note that in the XLHP_HAS_REDIRECTIONS variant, there are actually 2
412 * * length number of OffsetNumbers in the data.
413 */
414typedef struct xlhp_prune_items
415{
419
420
421/* flags for infobits_set */
422#define XLHL_XMAX_IS_MULTI 0x01
423#define XLHL_XMAX_LOCK_ONLY 0x02
424#define XLHL_XMAX_EXCL_LOCK 0x04
425#define XLHL_XMAX_KEYSHR_LOCK 0x08
426#define XLHL_KEYS_UPDATED 0x10
427
428/* flag bits for xl_heap_lock / xl_heap_lock_updated's flag field */
429#define XLH_LOCK_ALL_FROZEN_CLEARED 0x01
430
431/* This is what we need to know about lock */
432#define HEAP_LOCK_BLKREF_HEAP 0
433#define HEAP_LOCK_BLKREF_VM 1
434
435typedef struct xl_heap_lock
436{
437 TransactionId xmax; /* might be a MultiXactId */
438 OffsetNumber offnum; /* locked tuple's offset on page */
439 uint8 infobits_set; /* infomask and infomask2 bits to set */
440 uint8 flags; /* XLH_LOCK_* flag bits */
442
443#define SizeOfHeapLock (offsetof(xl_heap_lock, flags) + sizeof(uint8))
444
445/* This is what we need to know about locking an updated version of a row */
446typedef struct xl_heap_lock_updated
447{
451 uint8 flags;
453
454#define SizeOfHeapLockUpdated (offsetof(xl_heap_lock_updated, flags) + sizeof(uint8))
455
456/* This is what we need to know about confirmation of speculative insertion */
457typedef struct xl_heap_confirm
458{
459 OffsetNumber offnum; /* confirmed tuple's offset on page */
461
462#define SizeOfHeapConfirm (offsetof(xl_heap_confirm, offnum) + sizeof(OffsetNumber))
463
464/* This is what we need to know about in-place update */
465typedef struct xl_heap_inplace
466{
467 OffsetNumber offnum; /* updated tuple's offset on page */
468 Oid dbId; /* MyDatabaseId */
469 Oid tsId; /* MyDatabaseTableSpace */
470 bool relcacheInitFileInval; /* invalidate relcache init files */
471 int nmsgs; /* number of shared inval msgs */
474
475#define MinSizeOfHeapInplace (offsetof(xl_heap_inplace, nmsgs) + sizeof(int))
476
477typedef struct xl_heap_new_cid
478{
479 /*
480 * store toplevel xid so we don't have to merge cids from different
481 * transactions
482 */
486 CommandId combocid; /* just for debugging */
487
488 /*
489 * Store the relfilelocator/ctid pair to facilitate lookups.
490 */
494
495#define SizeOfHeapNewCid (offsetof(xl_heap_new_cid, target_tid) + sizeof(ItemPointerData))
496
497/* logical rewrite xlog record header */
498typedef struct xl_heap_rewrite_mapping
499{
500 TransactionId mapped_xid; /* xid that might need to see the row */
501 Oid mapped_db; /* DbOid or InvalidOid for shared rels */
502 Oid mapped_rel; /* Oid of the mapped relation */
503 off_t offset; /* How far have we written so far */
504 uint32 num_mappings; /* Number of in-memory mappings */
505 XLogRecPtr start_lsn; /* Insert LSN at begin of rewrite */
507
509 TransactionId *snapshotConflictHorizon);
510
511extern void heap_redo(XLogReaderState *record);
512extern void heap_desc(StringInfo buf, XLogReaderState *record);
513extern const char *heap_identify(uint8 info);
514extern void heap_mask(char *pagedata, BlockNumber blkno);
515extern void heap2_redo(XLogReaderState *record);
516extern void heap2_desc(StringInfo buf, XLogReaderState *record);
517extern const char *heap2_identify(uint8 info);
519
520/* in heapdesc.c, so it can be shared between frontend/backend code */
522 int *nplans, xlhp_freeze_plan **plans,
524 int *nredirected, OffsetNumber **redirected,
525 int *ndead, OffsetNumber **nowdead,
526 int *nunused, OffsetNumber **nowunused);
527
528#endif /* HEAPAM_XLOG_H */
uint32 BlockNumber
Definition block.h:31
uint8_t uint8
Definition c.h:681
#define FLEXIBLE_ARRAY_MEMBER
Definition c.h:617
uint16_t uint16
Definition c.h:682
uint32_t uint32
Definition c.h:683
uint32 CommandId
Definition c.h:809
uint32 TransactionId
Definition c.h:795
void heap_desc(StringInfo buf, XLogReaderState *record)
Definition heapdesc.c:185
void heap_redo(XLogReaderState *record)
void heap2_desc(StringInfo buf, XLogReaderState *record)
Definition heapdesc.c:265
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
void heap_mask(char *pagedata, BlockNumber blkno)
void HeapTupleHeaderAdvanceConflictHorizon(HeapTupleHeader tuple, TransactionId *snapshotConflictHorizon)
Definition heapam.c:8194
void heap_xlog_logical_rewrite(XLogReaderState *r)
const char * heap2_identify(uint8 info)
Definition heapdesc.c:442
const char * heap_identify(uint8 info)
Definition heapdesc.c:397
void heap2_redo(XLogReaderState *record)
uint16 OffsetNumber
Definition off.h:24
static char buf[DEFAULT_XLOG_SEG_SIZE]
unsigned int Oid
static int fb(int x)
Definition type.h:139
OffsetNumber offnum
OffsetNumber offnum
SharedInvalidationMessage msgs[FLEXIBLE_ARRAY_MEMBER]
bool relcacheInitFileInval
OffsetNumber offnum
TransactionId xmax
OffsetNumber offnum
uint8 infobits_set
OffsetNumber offnum
TransactionId xmax
OffsetNumber offsets[FLEXIBLE_ARRAY_MEMBER]
CommandId combocid
ItemPointerData target_tid
TransactionId top_xid
RelFileLocator target_locator
TransactionId mapped_xid
Oid relids[FLEXIBLE_ARRAY_MEMBER]
TransactionId new_xmax
uint8 old_infobits_set
TransactionId old_xmax
OffsetNumber old_offnum
OffsetNumber new_offnum
TransactionId xmax
xlhp_freeze_plan plans[FLEXIBLE_ARRAY_MEMBER]
OffsetNumber data[FLEXIBLE_ARRAY_MEMBER]
uint64 XLogRecPtr
Definition xlogdefs.h:21

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

#define XLH_DELETE_NO_LOGICAL   (1<<5)

Definition at line 108 of file heapam_xlog.h.

◆ XLH_FREEZE_XVAC

#define XLH_FREEZE_XVAC   0x02

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

◆ XLH_LOCK_ALL_FROZEN_CLEARED

#define XLH_LOCK_ALL_FROZEN_CLEARED   0x01

Definition at line 430 of file heapam_xlog.h.

◆ XLH_TRUNCATE_CASCADE

#define XLH_TRUNCATE_CASCADE   (1<<0)

Definition at line 131 of file heapam_xlog.h.

◆ XLH_TRUNCATE_RESTART_SEQS

#define XLH_TRUNCATE_RESTART_SEQS   (1<<1)

Definition at line 132 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

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 427 of file heapam_xlog.h.

◆ XLHL_XMAX_EXCL_LOCK

#define XLHL_XMAX_EXCL_LOCK   0x04

Definition at line 425 of file heapam_xlog.h.

◆ XLHL_XMAX_IS_MULTI

#define XLHL_XMAX_IS_MULTI   0x01

Definition at line 423 of file heapam_xlog.h.

◆ XLHL_XMAX_KEYSHR_LOCK

#define XLHL_XMAX_KEYSHR_LOCK   0x08

Definition at line 426 of file heapam_xlog.h.

◆ XLHL_XMAX_LOCK_ONLY

#define XLHL_XMAX_LOCK_ONLY   0x02

Definition at line 424 of file heapam_xlog.h.

◆ XLHP_CLEANUP_LOCK

#define XLHP_CLEANUP_LOCK   (1 << 2)

Definition at line 337 of file heapam_xlog.h.

◆ XLHP_HAS_CONFLICT_HORIZON

#define XLHP_HAS_CONFLICT_HORIZON   (1 << 3)

Definition at line 345 of file heapam_xlog.h.

◆ XLHP_HAS_DEAD_ITEMS

#define XLHP_HAS_DEAD_ITEMS   (1 << 6)

Definition at line 359 of file heapam_xlog.h.

◆ XLHP_HAS_FREEZE_PLANS

#define XLHP_HAS_FREEZE_PLANS   (1 << 4)

Definition at line 351 of file heapam_xlog.h.

◆ XLHP_HAS_NOW_UNUSED_ITEMS

#define XLHP_HAS_NOW_UNUSED_ITEMS   (1 << 7)

Definition at line 360 of file heapam_xlog.h.

◆ XLHP_HAS_REDIRECTIONS

#define XLHP_HAS_REDIRECTIONS   (1 << 5)

Definition at line 358 of file heapam_xlog.h.

◆ XLHP_IS_CATALOG_REL

#define XLHP_IS_CATALOG_REL   (1 << 1)

Definition at line 327 of file heapam_xlog.h.

◆ XLHP_VM_ALL_FROZEN

#define XLHP_VM_ALL_FROZEN   (1 << 9)

Definition at line 369 of file heapam_xlog.h.

◆ XLHP_VM_ALL_VISIBLE

#define XLHP_VM_ALL_VISIBLE   (1 << 8)

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

◆ xl_heap_lock_updated

◆ xl_heap_multi_insert

◆ xl_heap_new_cid

◆ xl_heap_prune

◆ xl_heap_rewrite_mapping

◆ xl_heap_truncate

◆ xl_heap_update

◆ xl_multi_insert_tuple

◆ xlhp_freeze_plan

◆ xlhp_freeze_plans

◆ xlhp_prune_items

Function Documentation

◆ heap2_desc()

void heap2_desc ( StringInfo  buf,
XLogReaderState record 
)
extern

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 {
276
277 if (xlrec->flags & XLHP_HAS_CONFLICT_HORIZON)
278 {
280
282
283 appendStringInfo(buf, "snapshotConflictHorizon: %u",
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)
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;
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,
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,
342 }
343
344 if (nunused > 0)
345 {
346 appendStringInfoString(buf, ", unused:");
347 array_desc(buf, nowunused, sizeof(OffsetNumber), nunused,
349 }
350 }
351 }
352 else if (info == XLOG_HEAP2_MULTI_INSERT)
353 {
355 bool isinit = (XLogRecGetInfo(record) & XLOG_HEAP_INIT_PAGE) != 0;
356
357 appendStringInfo(buf, "ntuples: %d, flags: 0x%02X", xlrec->ntuples,
358 xlrec->flags);
359
360 if (xlrec->flags & XLH_INSERT_ALL_FROZEN_SET)
361 appendStringInfo(buf, ", vm_flags: 0x%02X",
364
365 if (XLogRecHasBlockData(record, 0) && !isinit)
366 {
367 appendStringInfoString(buf, ", offsets:");
368 array_desc(buf, xlrec->offsets, sizeof(OffsetNumber),
369 xlrec->ntuples, &offset_elem_desc, NULL);
370 }
371 }
372 else if (info == XLOG_HEAP2_LOCK_UPDATED)
373 {
375
376 appendStringInfo(buf, "xmax: %u, off: %u, ",
377 xlrec->xmax, xlrec->offnum);
378 infobits_desc(buf, xlrec->infobits_set, "infobits");
379 appendStringInfo(buf, ", flags: 0x%02X", xlrec->flags);
380 }
381 else if (info == XLOG_HEAP2_NEW_CID)
382 {
384
385 appendStringInfo(buf, "rel: %u/%u/%u, tid: %u/%u",
386 xlrec->target_locator.spcOid,
387 xlrec->target_locator.dbOid,
388 xlrec->target_locator.relNumber,
389 ItemPointerGetBlockNumber(&(xlrec->target_tid)),
390 ItemPointerGetOffsetNumber(&(xlrec->target_tid)));
391 appendStringInfo(buf, ", cmin: %u, cmax: %u, combo: %u",
392 xlrec->cmin, xlrec->cmax, xlrec->combocid);
393 }
394}
size_t Size
Definition c.h:748
memcpy(sums, checksumBaseOffsets, sizeof(checksumBaseOffsets))
#define XLOG_HEAP2_MULTI_INSERT
Definition heapam_xlog.h:64
#define XLHP_HAS_CONFLICT_HORIZON
#define XLHP_VM_ALL_VISIBLE
#define XLH_INSERT_ALL_FROZEN_SET
Definition heapam_xlog.h:79
#define XLOG_HEAP_OPMASK
Definition heapam_xlog.h:42
#define SizeOfHeapPrune
#define XLHP_VM_ALL_FROZEN
#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 XLHP_IS_CATALOG_REL
#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
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
#define VISIBILITYMAP_ALL_FROZEN
#define VISIBILITYMAP_ALL_VISIBLE
char * XLogRecGetBlockData(XLogReaderState *record, uint8 block_id, Size *len)
#define XLogRecHasBlockData(decoder, block_id)
Definition xlogreader.h:427
#define XLogRecGetInfo(decoder)
Definition xlogreader.h:410
#define XLogRecGetData(decoder)
Definition xlogreader.h:415

References appendStringInfo(), appendStringInfoString(), array_desc(), buf, fb(), heap_xlog_deserialize_prune_and_freeze(), infobits_desc(), ItemPointerGetBlockNumber(), ItemPointerGetOffsetNumber(), memcpy(), offset_elem_desc(), plan_elem_desc(), redirect_elem_desc(), SizeOfHeapPrune, 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_HEAP_INIT_PAGE, XLOG_HEAP_OPMASK, XLogRecGetBlockData(), XLogRecGetData, XLogRecGetInfo, and XLogRecHasBlockData.

◆ heap2_identify()

const char * heap2_identify ( uint8  info)
extern

Definition at line 442 of file heapdesc.c.

443{
444 const char *id = NULL;
445
446 switch (info & ~XLR_INFO_MASK)
447 {
449 id = "PRUNE_ON_ACCESS";
450 break;
452 id = "PRUNE_VACUUM_SCAN";
453 break;
455 id = "PRUNE_VACUUM_CLEANUP";
456 break;
458 id = "MULTI_INSERT";
459 break;
461 id = "MULTI_INSERT+INIT";
462 break;
464 id = "LOCK_UPDATED";
465 break;
467 id = "NEW_CID";
468 break;
470 id = "REWRITE";
471 break;
472 }
473
474 return id;
475}
#define XLOG_HEAP2_REWRITE
Definition heapam_xlog.h:59
#define XLR_INFO_MASK
Definition xlogrecord.h:62

References fb(), 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_HEAP_INIT_PAGE, and XLR_INFO_MASK.

◆ heap2_redo()

void heap2_redo ( XLogReaderState record)
extern

Definition at line 1313 of file heapam_xlog.c.

1314{
1315 uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
1316
1317 switch (info & XLOG_HEAP_OPMASK)
1318 {
1322 heap_xlog_prune_freeze(record);
1323 break;
1325 heap_xlog_multi_insert(record);
1326 break;
1328 heap_xlog_lock_updated(record);
1329 break;
1330 case XLOG_HEAP2_NEW_CID:
1331
1332 /*
1333 * Nothing to do on a real replay, only used during logical
1334 * decoding.
1335 */
1336 break;
1337 case XLOG_HEAP2_REWRITE:
1339 break;
1340 default:
1341 elog(PANIC, "heap2_redo: unknown op code %u", info);
1342 }
1343}
#define PANIC
Definition elog.h:44
#define elog(elevel,...)
Definition elog.h:228
static void heap_xlog_prune_freeze(XLogReaderState *record)
Definition heapam_xlog.c:70
static void heap_xlog_lock_updated(XLogReaderState *record)
static void heap_xlog_multi_insert(XLogReaderState *record)
void heap_xlog_logical_rewrite(XLogReaderState *r)

References elog, fb(), heap_xlog_lock_updated(), heap_xlog_logical_rewrite(), heap_xlog_multi_insert(), heap_xlog_prune_freeze(), 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_HEAP_OPMASK, and XLogRecGetInfo.

◆ heap_desc()

void heap_desc ( StringInfo  buf,
XLogReaderState record 
)
extern

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 {
194
195 appendStringInfo(buf, "off: %u, flags: 0x%02X",
196 xlrec->offnum,
197 xlrec->flags);
198 }
199 else if (info == XLOG_HEAP_DELETE)
200 {
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 {
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 {
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 {
231
233 appendStringInfo(buf, ", nrelids: %u", xlrec->nrelids);
234 appendStringInfoString(buf, ", relids:");
235 array_desc(buf, xlrec->relids, sizeof(Oid), xlrec->nrelids,
237 }
238 else if (info == XLOG_HEAP_CONFIRM)
239 {
241
242 appendStringInfo(buf, "off: %u", xlrec->offnum);
243 }
244 else if (info == XLOG_HEAP_LOCK)
245 {
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 {
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
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)

References appendStringInfo(), appendStringInfoString(), array_desc(), buf, fb(), infobits_desc(), oid_elem_desc(), standby_desc_invalidations(), 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, and XLogRecGetInfo.

◆ heap_identify()

const char * heap_identify ( uint8  info)
extern

Definition at line 397 of file heapdesc.c.

398{
399 const char *id = NULL;
400
401 switch (info & ~XLR_INFO_MASK)
402 {
403 case XLOG_HEAP_INSERT:
404 id = "INSERT";
405 break;
407 id = "INSERT+INIT";
408 break;
409 case XLOG_HEAP_DELETE:
410 id = "DELETE";
411 break;
412 case XLOG_HEAP_UPDATE:
413 id = "UPDATE";
414 break;
416 id = "UPDATE+INIT";
417 break;
419 id = "HOT_UPDATE";
420 break;
422 id = "HOT_UPDATE+INIT";
423 break;
425 id = "TRUNCATE";
426 break;
428 id = "HEAP_CONFIRM";
429 break;
430 case XLOG_HEAP_LOCK:
431 id = "LOCK";
432 break;
434 id = "INPLACE";
435 break;
436 }
437
438 return id;
439}

References fb(), 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 
)
extern

Definition at line 1349 of file heapam_xlog.c.

1350{
1351 Page page = (Page) pagedata;
1352 OffsetNumber off;
1353
1355
1356 mask_page_hint_bits(page);
1357 mask_unused_space(page);
1358
1359 for (off = 1; off <= PageGetMaxOffsetNumber(page); off++)
1360 {
1361 ItemId iid = PageGetItemId(page, off);
1362 char *page_item;
1363
1364 page_item = (char *) (page + ItemIdGetOffset(iid));
1365
1366 if (ItemIdIsNormal(iid))
1367 {
1369
1370 /*
1371 * If xmin of a tuple is not yet frozen, we should ignore
1372 * differences in hint bits, since they can be set without
1373 * emitting WAL.
1374 */
1377 else
1378 {
1379 /* Still we need to mask xmax hint bits. */
1380 page_htup->t_infomask &= ~HEAP_XMAX_INVALID;
1381 page_htup->t_infomask &= ~HEAP_XMAX_COMMITTED;
1382 }
1383
1384 /*
1385 * During replay, we set Command Id to FirstCommandId. Hence, mask
1386 * it. See heap_xlog_insert() for details.
1387 */
1388 page_htup->t_choice.t_heap.t_field3.t_cid = MASK_MARKER;
1389
1390 /*
1391 * For a speculative tuple, heap_insert() does not set ctid in the
1392 * caller-passed heap tuple itself, leaving the ctid field to
1393 * contain a speculative token value - a per-backend monotonically
1394 * increasing identifier. Besides, it does not WAL-log ctid under
1395 * any circumstances.
1396 *
1397 * During redo, heap_xlog_insert() sets t_ctid to current block
1398 * number and self offset number. It doesn't care about any
1399 * speculative insertions on the primary. Hence, we set t_ctid to
1400 * current block number and self offset number to ignore any
1401 * inconsistency.
1402 */
1404 ItemPointerSet(&page_htup->t_ctid, blkno, off);
1405
1406 /*
1407 * NB: Not ignoring ctid changes due to the tuple having moved
1408 * (i.e. HeapTupleHeaderIndicatesMovedPartitions), because that's
1409 * important information that needs to be in-sync between primary
1410 * and standby, and thus is WAL logged.
1411 */
1412 }
1413
1414 /*
1415 * Ignore any padding bytes after the tuple, when the length of the
1416 * item is not MAXALIGNed.
1417 */
1418 if (ItemIdHasStorage(iid))
1419 {
1420 int len = ItemIdGetLength(iid);
1421 int padlen = MAXALIGN(len) - len;
1422
1423 if (padlen > 0)
1425 }
1426 }
1427}
void mask_page_lsn_and_checksum(Page page)
Definition bufmask.c:31
void mask_unused_space(Page page)
Definition bufmask.c:70
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:268
PageData * Page
Definition bufpage.h:81
static OffsetNumber PageGetMaxOffsetNumber(const PageData *page)
Definition bufpage.h:396
#define MAXALIGN(LEN)
Definition c.h:955
HeapTupleHeaderData * HeapTupleHeader
Definition htup.h:23
static bool HeapTupleHeaderXminFrozen(const HeapTupleHeaderData *tup)
#define HEAP_XACT_MASK
static bool HeapTupleHeaderIsSpeculative(const HeapTupleHeaderData *tup)
#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

References fb(), HEAP_XACT_MASK, 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)
extern

Definition at line 1267 of file heapam_xlog.c.

1268{
1269 uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK;
1270
1271 /*
1272 * These operations don't overwrite MVCC data so no conflict processing is
1273 * required. The ones in heap2 rmgr do.
1274 */
1275
1276 switch (info & XLOG_HEAP_OPMASK)
1277 {
1278 case XLOG_HEAP_INSERT:
1279 heap_xlog_insert(record);
1280 break;
1281 case XLOG_HEAP_DELETE:
1282 heap_xlog_delete(record);
1283 break;
1284 case XLOG_HEAP_UPDATE:
1285 heap_xlog_update(record, false);
1286 break;
1287 case XLOG_HEAP_TRUNCATE:
1288
1289 /*
1290 * TRUNCATE is a no-op because the actions are already logged as
1291 * SMGR WAL records. TRUNCATE WAL record only exists for logical
1292 * decoding.
1293 */
1294 break;
1296 heap_xlog_update(record, true);
1297 break;
1298 case XLOG_HEAP_CONFIRM:
1299 heap_xlog_confirm(record);
1300 break;
1301 case XLOG_HEAP_LOCK:
1302 heap_xlog_lock(record);
1303 break;
1304 case XLOG_HEAP_INPLACE:
1305 heap_xlog_inplace(record);
1306 break;
1307 default:
1308 elog(PANIC, "heap_redo: unknown op code %u", info);
1309 }
1310}
static void heap_xlog_insert(XLogReaderState *record)
static void heap_xlog_update(XLogReaderState *record, bool hot_update)
static void heap_xlog_delete(XLogReaderState *record)
static void heap_xlog_lock(XLogReaderState *record)
static void heap_xlog_inplace(XLogReaderState *record)
static void heap_xlog_confirm(XLogReaderState *record)

References elog, fb(), 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 
)
extern

Definition at line 106 of file heapdesc.c.

112{
113 if (flags & XLHP_HAS_FREEZE_PLANS)
114 {
116
117 *nplans = freeze_plans->nplans;
118 Assert(*nplans > 0);
119 *plans = freeze_plans->plans;
120
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
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
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
173 cursor += sizeof(OffsetNumber) * *nunused;
174 }
175 else
176 {
177 *nunused = 0;
178 *nowunused = NULL;
179 }
180
182}
#define Assert(condition)
Definition c.h:1002
#define XLHP_HAS_FREEZE_PLANS
#define XLHP_HAS_NOW_UNUSED_ITEMS
#define XLHP_HAS_REDIRECTIONS
#define XLHP_HAS_DEAD_ITEMS
const void * data

References Assert, data, fb(), 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)
extern

Definition at line 1080 of file rewriteheap.c.

1081{
1082 char path[MAXPGPATH];
1083 int fd;
1085 size_t len;
1086 char *data;
1087
1089
1090 snprintf(path, MAXPGPATH,
1092 PG_LOGICAL_MAPPINGS_DIR, xlrec->mapped_db, xlrec->mapped_rel,
1093 LSN_FORMAT_ARGS(xlrec->start_lsn),
1094 xlrec->mapped_xid, XLogRecGetXid(r));
1095
1096 fd = OpenTransientFile(path,
1098 if (fd < 0)
1099 ereport(ERROR,
1101 errmsg("could not create file \"%s\": %m", path)));
1102
1103 /*
1104 * Truncate all data that's not guaranteed to have been safely fsynced (by
1105 * previous record or by the last checkpoint).
1106 */
1108 if (ftruncate(fd, xlrec->offset) != 0)
1109 ereport(ERROR,
1111 errmsg("could not truncate file \"%s\" to %lld: %m",
1112 path, (long long int) xlrec->offset)));
1114
1115 data = XLogRecGetData(r) + sizeof(*xlrec);
1116
1117 len = xlrec->num_mappings * sizeof(LogicalRewriteMappingData);
1118
1119 /* write out tail end of mapping file (again) */
1120 errno = 0;
1122 if (pg_pwrite(fd, data, len, xlrec->offset) != len)
1123 {
1124 /* if write didn't set errno, assume problem is no disk space */
1125 if (errno == 0)
1126 errno = ENOSPC;
1127 ereport(ERROR,
1129 errmsg("could not write to file \"%s\": %m", path)));
1130 }
1132
1133 /*
1134 * Now fsync all previously written data. We could improve things and only
1135 * do this for the last write to a file, but the required bookkeeping
1136 * doesn't seem worth the trouble.
1137 */
1139 if (pg_fsync(fd) != 0)
1142 errmsg("could not fsync file \"%s\": %m", path)));
1144
1145 if (CloseTransientFile(fd) != 0)
1146 ereport(ERROR,
1148 errmsg("could not close file \"%s\": %m", path)));
1149}
#define PG_BINARY
Definition c.h:1431
int errcode_for_file_access(void)
Definition elog.c:898
#define ERROR
Definition elog.h:40
#define ereport(elevel,...)
Definition elog.h:152
int CloseTransientFile(int fd)
Definition fd.c:2855
int data_sync_elevel(int elevel)
Definition fd.c:3984
int pg_fsync(int fd)
Definition fd.c:390
int OpenTransientFile(const char *fileName, int fileFlags)
Definition fd.c:2678
static char * errmsg
#define MAXPGPATH
#define pg_pwrite
Definition port.h:249
#define snprintf
Definition port.h:261
static int fd(const char *x, int i)
#define PG_LOGICAL_MAPPINGS_DIR
#define LOGICAL_REWRITE_FORMAT
Definition rewriteheap.h:54
static void pgstat_report_wait_start(uint32 wait_event_info)
Definition wait_event.h:67
static void pgstat_report_wait_end(void)
Definition wait_event.h:83
#define LSN_FORMAT_ARGS(lsn)
Definition xlogdefs.h:47
#define XLogRecGetXid(decoder)
Definition xlogreader.h:412

References CloseTransientFile(), data, data_sync_elevel(), ereport, errcode_for_file_access(), errmsg, ERROR, fb(), fd(), len, LOGICAL_REWRITE_FORMAT, LSN_FORMAT_ARGS, MAXPGPATH, OpenTransientFile(), PG_BINARY, pg_fsync(), PG_LOGICAL_MAPPINGS_DIR, pg_pwrite, pgstat_report_wait_end(), pgstat_report_wait_start(), snprintf, XLogRecGetData, and XLogRecGetXid.

Referenced by heap2_redo().

◆ HeapTupleHeaderAdvanceConflictHorizon()

void HeapTupleHeaderAdvanceConflictHorizon ( HeapTupleHeader  tuple,
TransactionId snapshotConflictHorizon 
)
extern

Definition at line 8194 of file heapam.c.

8196{
8200
8201 if (tuple->t_infomask & HEAP_MOVED)
8202 {
8203 if (TransactionIdPrecedes(*snapshotConflictHorizon, xvac))
8204 *snapshotConflictHorizon = xvac;
8205 }
8206
8207 /*
8208 * Ignore tuples inserted by an aborted transaction or if the tuple was
8209 * updated/deleted by the inserting transaction.
8210 *
8211 * Look for a committed hint bit, or if no xmin bit is set, check clog.
8212 */
8213 if (HeapTupleHeaderXminCommitted(tuple) ||
8215 {
8216 if (xmax != xmin &&
8217 TransactionIdFollows(xmax, *snapshotConflictHorizon))
8218 *snapshotConflictHorizon = xmax;
8219 }
8220}
static bool HeapTupleHeaderXminInvalid(const HeapTupleHeaderData *tup)
static TransactionId HeapTupleHeaderGetXvac(const HeapTupleHeaderData *tup)
#define HEAP_MOVED
static TransactionId HeapTupleHeaderGetXmin(const HeapTupleHeaderData *tup)
static TransactionId HeapTupleHeaderGetUpdateXid(const HeapTupleHeaderData *tup)
static bool HeapTupleHeaderXminCommitted(const HeapTupleHeaderData *tup)
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 fb(), 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().