PostgreSQL Source Code git master
Loading...
Searching...
No Matches
heapam.h
Go to the documentation of this file.
1/*-------------------------------------------------------------------------
2 *
3 * heapam.h
4 * POSTGRES heap access method definitions.
5 *
6 *
7 * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
9 *
10 * src/include/access/heapam.h
11 *
12 *-------------------------------------------------------------------------
13 */
14#ifndef HEAPAM_H
15#define HEAPAM_H
16
17#include "access/heapam_xlog.h"
18#include "access/relation.h" /* for backward compatibility */
19#include "access/relscan.h"
20#include "access/sdir.h"
21#include "access/skey.h"
22#include "access/table.h" /* for backward compatibility */
23#include "access/tableam.h"
24#include "commands/vacuum.h"
25#include "nodes/lockoptions.h"
26#include "nodes/primnodes.h"
27#include "storage/bufpage.h"
28#include "storage/dsm.h"
29#include "storage/lockdefs.h"
30#include "storage/read_stream.h"
31#include "storage/shm_toc.h"
32#include "utils/relcache.h"
33#include "utils/snapshot.h"
34
35
36/* "options" flag bits for heap_insert */
37#define HEAP_INSERT_SKIP_FSM TABLE_INSERT_SKIP_FSM
38#define HEAP_INSERT_FROZEN TABLE_INSERT_FROZEN
39#define HEAP_INSERT_NO_LOGICAL TABLE_INSERT_NO_LOGICAL
40#define HEAP_INSERT_SPECULATIVE 0x0010
41
42/* "options" flag bits for heap_page_prune_and_freeze */
43#define HEAP_PAGE_PRUNE_MARK_UNUSED_NOW (1 << 0)
44#define HEAP_PAGE_PRUNE_FREEZE (1 << 1)
45
49struct VacuumCutoffs;
50
51#define MaxLockTupleMode LockTupleExclusive
52
53/*
54 * Descriptor for heap table scans.
55 */
56typedef struct HeapScanDescData
57{
58 TableScanDescData rs_base; /* AM independent part of the descriptor */
59
60 /* state set up at initscan time */
61 BlockNumber rs_nblocks; /* total number of blocks in rel */
62 BlockNumber rs_startblock; /* block # to start at */
63 BlockNumber rs_numblocks; /* max number of blocks to scan */
64 /* rs_numblocks is usually InvalidBlockNumber, meaning "scan whole rel" */
65
66 /* scan current state */
67 bool rs_inited; /* false = scan not init'd yet */
68 OffsetNumber rs_coffset; /* current offset # in non-page-at-a-time mode */
69 BlockNumber rs_cblock; /* current block # in scan, if any */
70 Buffer rs_cbuf; /* current buffer in scan, if any */
71 /* NB: if rs_cbuf is not InvalidBuffer, we hold a pin on that buffer */
72
73 BufferAccessStrategy rs_strategy; /* access strategy for reads */
74
75 HeapTupleData rs_ctup; /* current tuple in scan, if any */
76
77 /* For scans that stream reads */
79
80 /*
81 * For sequential scans and TID range scans to stream reads. The read
82 * stream is allocated at the beginning of the scan and reset on rescan or
83 * when the scan direction changes. The scan direction is saved each time
84 * a new page is requested. If the scan direction changes from one page to
85 * the next, the read stream releases all previously pinned buffers and
86 * resets the prefetch block.
87 */
90
91 /*
92 * For parallel scans to store page allocation data. NULL when not
93 * performing a parallel scan.
94 */
96
97 /* these fields only used in page-at-a-time mode and for bitmap scans */
98 uint32 rs_cindex; /* current tuple's index in vistuples */
99 uint32 rs_ntuples; /* number of visible tuples on page */
103
111
112/*
113 * Descriptor for fetches from heap via an index.
114 */
115typedef struct IndexFetchHeapData
116{
117 IndexFetchTableData xs_base; /* AM independent part of the descriptor */
118
119 Buffer xs_cbuf; /* current heap buffer in scan, if any */
120 /* NB: if xs_cbuf is not InvalidBuffer, we hold a pin on that buffer */
122
123/* Result codes for HeapTupleSatisfiesVacuum */
124typedef enum
125{
126 HEAPTUPLE_DEAD, /* tuple is dead and deletable */
127 HEAPTUPLE_LIVE, /* tuple is live (committed, no deleter) */
128 HEAPTUPLE_RECENTLY_DEAD, /* tuple is dead, but not deletable yet */
129 HEAPTUPLE_INSERT_IN_PROGRESS, /* inserting xact is still in progress */
130 HEAPTUPLE_DELETE_IN_PROGRESS, /* deleting xact is still in progress */
132
133/*
134 * heap_prepare_freeze_tuple may request that heap_freeze_execute_prepared
135 * check any tuple's to-be-frozen xmin and/or xmax status using pg_xact
136 */
137#define HEAP_FREEZE_CHECK_XMIN_COMMITTED 0x01
138#define HEAP_FREEZE_CHECK_XMAX_ABORTED 0x02
139
140/* heap_prepare_freeze_tuple state describing how to freeze a tuple */
141typedef struct HeapTupleFreeze
142{
143 /* Fields describing how to process tuple */
148
149 /* xmin/xmax check flags */
151 /* Page offset number for tuple */
154
155/*
156 * State used by VACUUM to track the details of freezing all eligible tuples
157 * on a given heap page.
158 *
159 * VACUUM prepares freeze plans for each page via heap_prepare_freeze_tuple
160 * calls (every tuple with storage gets its own call). This page-level freeze
161 * state is updated across each call, which ultimately determines whether or
162 * not freezing the page is required.
163 *
164 * Aside from the basic question of whether or not freezing will go ahead, the
165 * state also tracks the oldest extant XID/MXID in the table as a whole, for
166 * the purposes of advancing relfrozenxid/relminmxid values in pg_class later
167 * on. Each heap_prepare_freeze_tuple call pushes NewRelfrozenXid and/or
168 * NewRelminMxid back as required to avoid unsafe final pg_class values. Any
169 * and all unfrozen XIDs or MXIDs that remain after VACUUM finishes _must_
170 * have values >= the final relfrozenxid/relminmxid values in pg_class. This
171 * includes XIDs that remain as MultiXact members from any tuple's xmax.
172 *
173 * When 'freeze_required' flag isn't set after all tuples are examined, the
174 * final choice on freezing is made by vacuumlazy.c. It can decide to trigger
175 * freezing based on whatever criteria it deems appropriate. However, it is
176 * recommended that vacuumlazy.c avoid early freezing when freezing does not
177 * enable setting the target page all-frozen in the visibility map afterwards.
178 */
179typedef struct HeapPageFreeze
180{
181 /* Is heap_prepare_freeze_tuple caller required to freeze page? */
183
184 /*
185 * "Freeze" NewRelfrozenXid/NewRelminMxid trackers.
186 *
187 * Trackers used when heap_freeze_execute_prepared freezes, or when there
188 * are zero freeze plans for a page. It is always valid for vacuumlazy.c
189 * to freeze any page, by definition. This even includes pages that have
190 * no tuples with storage to consider in the first place. That way the
191 * 'totally_frozen' results from heap_prepare_freeze_tuple can always be
192 * used in the same way, even when no freeze plans need to be executed to
193 * "freeze the page". Only the "freeze" path needs to consider the need
194 * to set pages all-frozen in the visibility map under this scheme.
195 *
196 * When we freeze a page, we generally freeze all XIDs < OldestXmin, only
197 * leaving behind XIDs that are ineligible for freezing, if any. And so
198 * you might wonder why these trackers are necessary at all; why should
199 * _any_ page that VACUUM freezes _ever_ be left with XIDs/MXIDs that
200 * ratchet back the top-level NewRelfrozenXid/NewRelminMxid trackers?
201 *
202 * It is useful to use a definition of "freeze the page" that does not
203 * overspecify how MultiXacts are affected. heap_prepare_freeze_tuple
204 * generally prefers to remove Multis eagerly, but lazy processing is used
205 * in cases where laziness allows VACUUM to avoid allocating a new Multi.
206 * The "freeze the page" trackers enable this flexibility.
207 */
210
211 /*
212 * Newest XID that this page's freeze actions will remove from tuple
213 * visibility metadata (currently xmin and/or xvac). It is used to derive
214 * the snapshot conflict horizon for a WAL record that freezes tuples. On
215 * a standby, we must not replay that change while any snapshot could
216 * still treat that XID as running.
217 *
218 * It's only used if we execute freeze plans for this page, so there is no
219 * corresponding "no freeze" tracker.
220 */
222
223 /*
224 * "No freeze" NewRelfrozenXid/NewRelminMxid trackers.
225 *
226 * These trackers are maintained in the same way as the trackers used when
227 * VACUUM scans a page that isn't cleanup locked. Both code paths are
228 * based on the same general idea (do less work for this page during the
229 * ongoing VACUUM, at the cost of having to accept older final values).
230 */
233
235
236
237/* 'reason' codes for heap_page_prune_and_freeze() */
238typedef enum
239{
240 PRUNE_ON_ACCESS, /* on-access pruning */
241 PRUNE_VACUUM_SCAN, /* VACUUM 1st heap pass */
242 PRUNE_VACUUM_CLEANUP, /* VACUUM 2nd heap pass */
244
245/*
246 * Input parameters to heap_page_prune_and_freeze()
247 */
248typedef struct PruneFreezeParams
249{
250 Relation relation; /* relation containing buffer to be pruned */
251 Buffer buffer; /* buffer to be pruned */
252
253 /*
254 * The reason pruning was performed. It is used to set the WAL record
255 * opcode which is used for debugging and analysis purposes.
256 */
258
259 /*
260 * Contains flag bits:
261 *
262 * HEAP_PAGE_PRUNE_MARK_UNUSED_NOW indicates that dead items can be set
263 * LP_UNUSED during pruning.
264 *
265 * HEAP_PAGE_PRUNE_FREEZE indicates that we will also freeze tuples, and
266 * will return 'all_visible', 'all_frozen' flags to the caller.
267 */
269
270 /*
271 * vistest is used to distinguish whether tuples are DEAD or RECENTLY_DEAD
272 * (see heap_prune_satisfies_vacuum).
273 */
275
276 /*
277 * Contains the cutoffs used for freezing. They are required if the
278 * HEAP_PAGE_PRUNE_FREEZE option is set. cutoffs->OldestXmin is also used
279 * to determine if dead tuples are HEAPTUPLE_RECENTLY_DEAD or
280 * HEAPTUPLE_DEAD. Currently only vacuum passes in cutoffs. Vacuum
281 * calculates them once, at the beginning of vacuuming the relation.
282 */
285
286/*
287 * Per-page state returned by heap_page_prune_and_freeze()
288 */
289typedef struct PruneFreezeResult
290{
291 int ndeleted; /* Number of tuples deleted from the page */
292 int nnewlpdead; /* Number of newly LP_DEAD items */
293 int nfrozen; /* Number of tuples we froze */
294
295 /* Number of live and recently dead tuples on the page, after pruning */
298
299 /*
300 * set_all_visible and set_all_frozen indicate if the all-visible and
301 * all-frozen bits in the visibility map should be set for this page after
302 * pruning.
303 *
304 * vm_conflict_horizon is the newest xmin of live tuples on the page. The
305 * caller can use it as the conflict horizon when setting the VM bits. It
306 * is only valid if we froze some tuples (nfrozen > 0), and set_all_frozen
307 * is true.
308 *
309 * These are only set if the HEAP_PAGE_PRUNE_FREEZE option is set.
310 */
314
315 /*
316 * Whether or not the page makes rel truncation unsafe. This is set to
317 * 'true', even if the page contains LP_DEAD items. VACUUM will remove
318 * them before attempting to truncate.
319 */
320 bool hastup;
321
322 /*
323 * LP_DEAD items on the page after pruning. Includes existing LP_DEAD
324 * items.
325 */
329
330
331/* ----------------
332 * function prototypes for heap access method
333 *
334 * heap_create, heap_create_with_catalog, and heap_drop_with_catalog
335 * are declared in catalog/heap.h
336 * ----------------
337 */
338
339
340extern TableScanDesc heap_beginscan(Relation relation, Snapshot snapshot,
341 int nkeys, ScanKey key,
342 ParallelTableScanDesc parallel_scan,
343 uint32 flags);
347extern void heap_rescan(TableScanDesc sscan, ScanKey key, bool set_params,
348 bool allow_strat, bool allow_sync, bool allow_pagemode);
349extern void heap_endscan(TableScanDesc sscan);
352 ScanDirection direction, TupleTableSlot *slot);
356 ScanDirection direction,
357 TupleTableSlot *slot);
358extern bool heap_fetch(Relation relation, Snapshot snapshot,
359 HeapTuple tuple, Buffer *userbuf, bool keep_buf);
360extern bool heap_hot_search_buffer(ItemPointer tid, Relation relation,
361 Buffer buffer, Snapshot snapshot, HeapTuple heapTuple,
362 bool *all_dead, bool first_call);
363
365
368extern void ReleaseBulkInsertStatePin(BulkInsertState bistate);
369
370extern void heap_insert(Relation relation, HeapTuple tup, CommandId cid,
371 int options, BulkInsertState bistate);
372extern void heap_multi_insert(Relation relation, TupleTableSlot **slots,
373 int ntuples, CommandId cid, int options,
374 BulkInsertState bistate);
375extern TM_Result heap_delete(Relation relation, const ItemPointerData *tid,
376 CommandId cid, Snapshot crosscheck, bool wait,
377 TM_FailureData *tmfd, bool changingPart);
378extern void heap_finish_speculative(Relation relation, const ItemPointerData *tid);
379extern void heap_abort_speculative(Relation relation, const ItemPointerData *tid);
380extern TM_Result heap_update(Relation relation, const ItemPointerData *otid,
382 CommandId cid, Snapshot crosscheck, bool wait,
383 TM_FailureData *tmfd, LockTupleMode *lockmode,
385extern TM_Result heap_lock_tuple(Relation relation, HeapTuple tuple,
387 bool follow_updates,
388 Buffer *buffer, TM_FailureData *tmfd);
389
390extern bool heap_inplace_lock(Relation relation,
392 void (*release_callback) (void *), void *arg);
393extern void heap_inplace_update_and_unlock(Relation relation,
395 Buffer buffer);
396extern void heap_inplace_unlock(Relation relation,
397 HeapTuple oldtup, Buffer buffer);
399 const struct VacuumCutoffs *cutoffs,
400 HeapPageFreeze *pagefrz,
402
403extern void heap_pre_freeze_checks(Buffer buffer,
404 HeapTupleFreeze *tuples, int ntuples);
405extern void heap_freeze_prepared_tuples(Buffer buffer,
406 HeapTupleFreeze *tuples, int ntuples);
407extern bool heap_freeze_tuple(HeapTupleHeader tuple,
408 TransactionId relfrozenxid, TransactionId relminmxid,
409 TransactionId FreezeLimit, TransactionId MultiXactCutoff);
411 const struct VacuumCutoffs *cutoffs,
412 TransactionId *NoFreezePageRelfrozenXid,
413 MultiXactId *NoFreezePageRelminMxid);
415
416extern void simple_heap_insert(Relation relation, HeapTuple tup);
417extern void simple_heap_delete(Relation relation, const ItemPointerData *tid);
418extern void simple_heap_update(Relation relation, const ItemPointerData *otid,
420
423
424/* in heap/pruneheap.c */
425extern void heap_page_prune_opt(Relation relation, Buffer buffer);
431extern void heap_page_prune_execute(Buffer buffer, bool lp_truncate_only,
432 OffsetNumber *redirected, int nredirected,
433 OffsetNumber *nowdead, int ndead,
434 OffsetNumber *nowunused, int nunused);
436extern void log_heap_prune_and_freeze(Relation relation, Buffer buffer,
437 Buffer vmbuffer, uint8 vmflags,
439 bool cleanup_lock,
440 PruneReason reason,
441 HeapTupleFreeze *frozen, int nfrozen,
442 OffsetNumber *redirected, int nredirected,
443 OffsetNumber *dead, int ndead,
444 OffsetNumber *unused, int nunused);
445
446/* in heap/vacuumlazy.c */
447extern void heap_vacuum_rel(Relation rel,
448 const VacuumParams params, BufferAccessStrategy bstrategy);
449
450/* in heap/heapam_visibility.c */
451extern bool HeapTupleSatisfiesVisibility(HeapTuple htup, Snapshot snapshot,
452 Buffer buffer);
454 Buffer buffer);
456 Buffer buffer);
459extern void HeapTupleSetHintBits(HeapTupleHeader tuple, Buffer buffer,
462extern bool HeapTupleIsSurelyDead(HeapTuple htup,
463 GlobalVisState *vistest);
464
465/*
466 * Some of the input/output to/from HeapTupleSatisfiesMVCCBatch() is passed
467 * via this struct, as otherwise the increased number of arguments to
468 * HeapTupleSatisfiesMVCCBatch() leads to on-stack argument passing on x86-64,
469 * which causes a small regression.
470 */
476
477extern int HeapTupleSatisfiesMVCCBatch(Snapshot snapshot, Buffer buffer,
478 int ntups,
481
482/*
483 * To avoid leaking too much knowledge about reorderbuffer implementation
484 * details this is implemented in reorderbuffer.c not heapam_visibility.c
485 */
486struct HTAB;
488 Snapshot snapshot,
489 HeapTuple htup,
490 Buffer buffer,
491 CommandId *cmin, CommandId *cmax);
492extern void HeapCheckForSerializableConflictOut(bool visible, Relation relation, HeapTuple tuple,
493 Buffer buffer, Snapshot snapshot);
494
495/*
496 * heap_execute_freeze_tuple
497 * Execute the prepared freezing of a tuple with caller's freeze plan.
498 *
499 * Caller is responsible for ensuring that no other backend can access the
500 * storage underlying this tuple, either by holding an exclusive lock on the
501 * buffer containing it (which is what lazy VACUUM does), or by having it be
502 * in private storage (which is what CLUSTER and friends do).
503 */
504static inline void
506{
507 HeapTupleHeaderSetXmax(tuple, frz->xmax);
508
509 if (frz->frzflags & XLH_FREEZE_XVAC)
511
512 if (frz->frzflags & XLH_INVALID_XVAC)
514
515 tuple->t_infomask = frz->t_infomask;
516 tuple->t_infomask2 = frz->t_infomask2;
517}
518
519#endif /* HEAPAM_H */
uint32 BlockNumber
Definition block.h:31
int Buffer
Definition buf.h:23
PageData * Page
Definition bufpage.h:81
uint8_t uint8
Definition c.h:586
TransactionId MultiXactId
Definition c.h:718
uint16_t uint16
Definition c.h:587
uint32_t uint32
Definition c.h:588
uint32 CommandId
Definition c.h:722
uint32 TransactionId
Definition c.h:708
Datum arg
Definition elog.c:1322
void simple_heap_update(Relation relation, const ItemPointerData *otid, HeapTuple tup, TU_UpdateIndexes *update_indexes)
Definition heapam.c:4557
void heap_insert(Relation relation, HeapTuple tup, CommandId cid, int options, BulkInsertState bistate)
Definition heapam.c:2142
bool heap_inplace_lock(Relation relation, HeapTuple oldtup_ptr, Buffer buffer, void(*release_callback)(void *), void *arg)
Definition heapam.c:6438
bool heap_fetch(Relation relation, Snapshot snapshot, HeapTuple tuple, Buffer *userbuf, bool keep_buf)
Definition heapam.c:1659
void HeapTupleSetHintBits(HeapTupleHeader tuple, Buffer buffer, uint16 infomask, TransactionId xid)
bool HeapTupleSatisfiesVisibility(HeapTuple htup, Snapshot snapshot, Buffer buffer)
HTSV_Result HeapTupleSatisfiesVacuumHorizon(HeapTuple htup, Buffer buffer, TransactionId *dead_after)
struct HeapScanDescData * HeapScanDesc
Definition heapam.h:102
void heap_vacuum_rel(Relation rel, const VacuumParams params, BufferAccessStrategy bstrategy)
Definition vacuumlazy.c:627
void heap_get_root_tuples(Page page, OffsetNumber *root_offsets)
Definition pruneheap.c:1886
void heap_finish_speculative(Relation relation, const ItemPointerData *tid)
Definition heapam.c:6169
void heap_page_prune_opt(Relation relation, Buffer buffer)
Definition pruneheap.c:212
HTSV_Result
Definition heapam.h:125
@ HEAPTUPLE_RECENTLY_DEAD
Definition heapam.h:128
@ HEAPTUPLE_INSERT_IN_PROGRESS
Definition heapam.h:129
@ HEAPTUPLE_LIVE
Definition heapam.h:127
@ HEAPTUPLE_DELETE_IN_PROGRESS
Definition heapam.h:130
@ HEAPTUPLE_DEAD
Definition heapam.h:126
bool heap_getnextslot(TableScanDesc sscan, ScanDirection direction, TupleTableSlot *slot)
Definition heapam.c:1449
void heap_page_prune_and_freeze(PruneFreezeParams *params, PruneFreezeResult *presult, OffsetNumber *off_loc, TransactionId *new_relfrozen_xid, MultiXactId *new_relmin_mxid)
Definition pruneheap.c:811
void heap_endscan(TableScanDesc sscan)
Definition heapam.c:1371
void heap_rescan(TableScanDesc sscan, ScanKey key, bool set_params, bool allow_strat, bool allow_sync, bool allow_pagemode)
Definition heapam.c:1318
void heap_inplace_unlock(Relation relation, HeapTuple oldtup, Buffer buffer)
Definition heapam.c:6716
TM_Result heap_update(Relation relation, const ItemPointerData *otid, HeapTuple newtup, CommandId cid, Snapshot crosscheck, bool wait, TM_FailureData *tmfd, LockTupleMode *lockmode, TU_UpdateIndexes *update_indexes)
Definition heapam.c:3313
struct BitmapHeapScanDescData * BitmapHeapScanDesc
Definition heapam.h:110
bool heap_tuple_needs_eventual_freeze(HeapTupleHeader tuple)
Definition heapam.c:7897
TM_Result heap_delete(Relation relation, const ItemPointerData *tid, CommandId cid, Snapshot crosscheck, bool wait, TM_FailureData *tmfd, bool changingPart)
Definition heapam.c:2844
bool ResolveCminCmaxDuringDecoding(struct HTAB *tuplecid_data, Snapshot snapshot, HeapTuple htup, Buffer buffer, CommandId *cmin, CommandId *cmax)
void log_heap_prune_and_freeze(Relation relation, Buffer buffer, Buffer vmbuffer, uint8 vmflags, TransactionId conflict_xid, bool cleanup_lock, PruneReason reason, HeapTupleFreeze *frozen, int nfrozen, OffsetNumber *redirected, int nredirected, OffsetNumber *dead, int ndead, OffsetNumber *unused, int nunused)
Definition pruneheap.c:2158
bool heap_tuple_should_freeze(HeapTupleHeader tuple, const struct VacuumCutoffs *cutoffs, TransactionId *NoFreezePageRelfrozenXid, MultiXactId *NoFreezePageRelminMxid)
Definition heapam.c:7952
bool heap_freeze_tuple(HeapTupleHeader tuple, TransactionId relfrozenxid, TransactionId relminmxid, TransactionId FreezeLimit, TransactionId MultiXactCutoff)
Definition heapam.c:7488
void heap_inplace_update_and_unlock(Relation relation, HeapTuple oldtup, HeapTuple tuple, Buffer buffer)
Definition heapam.c:6576
void ReleaseBulkInsertStatePin(BulkInsertState bistate)
Definition heapam.c:2104
bool HeapTupleIsSurelyDead(HeapTuple htup, GlobalVisState *vistest)
HeapTuple heap_getnext(TableScanDesc sscan, ScanDirection direction)
Definition heapam.c:1410
bool heap_hot_search_buffer(ItemPointer tid, Relation relation, Buffer buffer, Snapshot snapshot, HeapTuple heapTuple, bool *all_dead, bool first_call)
Definition heapam.c:1779
void heap_freeze_prepared_tuples(Buffer buffer, HeapTupleFreeze *tuples, int ntuples)
Definition heapam.c:7466
static void heap_execute_freeze_tuple(HeapTupleHeader tuple, HeapTupleFreeze *frz)
Definition heapam.h:505
bool heap_getnextslot_tidrange(TableScanDesc sscan, ScanDirection direction, TupleTableSlot *slot)
Definition heapam.c:1552
void heap_set_tidrange(TableScanDesc sscan, ItemPointer mintid, ItemPointer maxtid)
Definition heapam.c:1479
HTSV_Result HeapTupleSatisfiesVacuum(HeapTuple htup, TransactionId OldestXmin, Buffer buffer)
void heap_abort_speculative(Relation relation, const ItemPointerData *tid)
Definition heapam.c:6256
TableScanDesc heap_beginscan(Relation relation, Snapshot snapshot, int nkeys, ScanKey key, ParallelTableScanDesc parallel_scan, uint32 flags)
Definition heapam.c:1164
void heap_prepare_pagescan(TableScanDesc sscan)
Definition heapam.c:616
int HeapTupleSatisfiesMVCCBatch(Snapshot snapshot, Buffer buffer, int ntups, BatchMVCCState *batchmvcc, OffsetNumber *vistuples_dense)
void simple_heap_insert(Relation relation, HeapTuple tup)
Definition heapam.c:2786
bool heap_prepare_freeze_tuple(HeapTupleHeader tuple, const struct VacuumCutoffs *cutoffs, HeapPageFreeze *pagefrz, HeapTupleFreeze *frz, bool *totally_frozen)
Definition heapam.c:7133
void simple_heap_delete(Relation relation, const ItemPointerData *tid)
Definition heapam.c:3267
TransactionId heap_index_delete_tuples(Relation rel, TM_IndexDeleteOp *delstate)
Definition heapam.c:8205
bool HeapTupleHeaderIsOnlyLocked(HeapTupleHeader tuple)
PruneReason
Definition heapam.h:239
@ PRUNE_VACUUM_CLEANUP
Definition heapam.h:242
@ PRUNE_ON_ACCESS
Definition heapam.h:240
@ PRUNE_VACUUM_SCAN
Definition heapam.h:241
void heap_multi_insert(Relation relation, TupleTableSlot **slots, int ntuples, CommandId cid, int options, BulkInsertState bistate)
Definition heapam.c:2413
void heap_page_prune_execute(Buffer buffer, bool lp_truncate_only, OffsetNumber *redirected, int nredirected, OffsetNumber *nowdead, int ndead, OffsetNumber *nowunused, int nunused)
Definition pruneheap.c:1662
TM_Result heap_lock_tuple(Relation relation, HeapTuple tuple, CommandId cid, LockTupleMode mode, LockWaitPolicy wait_policy, bool follow_updates, Buffer *buffer, TM_FailureData *tmfd)
Definition heapam.c:4645
TM_Result HeapTupleSatisfiesUpdate(HeapTuple htup, CommandId curcid, Buffer buffer)
struct BulkInsertStateData * BulkInsertState
Definition heapam.h:46
void heap_get_latest_tid(TableScanDesc sscan, ItemPointer tid)
Definition heapam.c:1931
void heap_setscanlimits(TableScanDesc sscan, BlockNumber startBlk, BlockNumber numBlks)
Definition heapam.c:500
void HeapCheckForSerializableConflictOut(bool visible, Relation relation, HeapTuple tuple, Buffer buffer, Snapshot snapshot)
Definition heapam.c:9332
void FreeBulkInsertState(BulkInsertState)
Definition heapam.c:2092
void heap_pre_freeze_checks(Buffer buffer, HeapTupleFreeze *tuples, int ntuples)
Definition heapam.c:7413
BulkInsertState GetBulkInsertState(void)
Definition heapam.c:2075
#define XLH_INVALID_XVAC
#define XLH_FREEZE_XVAC
static void HeapTupleHeaderSetXvac(HeapTupleHeaderData *tup, TransactionId xid)
#define MaxHeapTuplesPerPage
static void HeapTupleHeaderSetXmax(HeapTupleHeaderData *tup, TransactionId xid)
LockWaitPolicy
Definition lockoptions.h:38
LockTupleMode
Definition lockoptions.h:51
uint16 OffsetNumber
Definition off.h:24
static PgChecksumMode mode
static int fb(int x)
ScanDirection
Definition sdir.h:25
static HTAB * tuplecid_data
Definition snapmgr.c:163
bool visible[MaxHeapTuplesPerPage]
Definition heapam.h:474
HeapTupleData tuples[MaxHeapTuplesPerPage]
Definition heapam.h:473
HeapScanDescData rs_heap_base
Definition heapam.h:106
MultiXactId NoFreezePageRelminMxid
Definition heapam.h:232
TransactionId FreezePageConflictXid
Definition heapam.h:221
TransactionId FreezePageRelfrozenXid
Definition heapam.h:208
bool freeze_required
Definition heapam.h:182
MultiXactId FreezePageRelminMxid
Definition heapam.h:209
TransactionId NoFreezePageRelfrozenXid
Definition heapam.h:231
BufferAccessStrategy rs_strategy
Definition heapam.h:73
ScanDirection rs_dir
Definition heapam.h:88
uint32 rs_ntuples
Definition heapam.h:99
OffsetNumber rs_coffset
Definition heapam.h:68
Buffer rs_cbuf
Definition heapam.h:70
ParallelBlockTableScanWorkerData * rs_parallelworkerdata
Definition heapam.h:95
BlockNumber rs_startblock
Definition heapam.h:62
HeapTupleData rs_ctup
Definition heapam.h:75
OffsetNumber rs_vistuples[MaxHeapTuplesPerPage]
Definition heapam.h:100
BlockNumber rs_numblocks
Definition heapam.h:63
BlockNumber rs_nblocks
Definition heapam.h:61
ReadStream * rs_read_stream
Definition heapam.h:78
uint32 rs_cindex
Definition heapam.h:98
BlockNumber rs_prefetch_block
Definition heapam.h:89
BlockNumber rs_cblock
Definition heapam.h:69
TableScanDescData rs_base
Definition heapam.h:58
uint8 frzflags
Definition heapam.h:147
uint16 t_infomask2
Definition heapam.h:145
TransactionId xmax
Definition heapam.h:144
OffsetNumber offset
Definition heapam.h:152
uint8 checkflags
Definition heapam.h:150
uint16 t_infomask
Definition heapam.h:146
IndexFetchTableData xs_base
Definition heapam.h:117
PruneReason reason
Definition heapam.h:257
GlobalVisState * vistest
Definition heapam.h:274
struct VacuumCutoffs * cutoffs
Definition heapam.h:283
Relation relation
Definition heapam.h:250
int recently_dead_tuples
Definition heapam.h:297
bool set_all_frozen
Definition heapam.h:312
TransactionId vm_conflict_horizon
Definition heapam.h:313
OffsetNumber deadoffsets[MaxHeapTuplesPerPage]
Definition heapam.h:327
bool set_all_visible
Definition heapam.h:311
TU_UpdateIndexes
Definition tableam.h:111
TM_Result
Definition tableam.h:73
#define FrozenTransactionId
Definition transam.h:33
#define InvalidTransactionId
Definition transam.h:31