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 "nodes/lockoptions.h"
25#include "nodes/primnodes.h"
26#include "storage/bufpage.h"
27#include "storage/dsm.h"
28#include "storage/lockdefs.h"
29#include "storage/read_stream.h"
30#include "storage/shm_toc.h"
31#include "utils/relcache.h"
32#include "utils/snapshot.h"
33
34
35/* "options" flag bits for heap_insert */
36#define HEAP_INSERT_SKIP_FSM TABLE_INSERT_SKIP_FSM
37#define HEAP_INSERT_FROZEN TABLE_INSERT_FROZEN
38#define HEAP_INSERT_NO_LOGICAL TABLE_INSERT_NO_LOGICAL
39#define HEAP_INSERT_SPECULATIVE 0x0010
40
41/* "options" flag bits for heap_page_prune_and_freeze */
42#define HEAP_PAGE_PRUNE_MARK_UNUSED_NOW (1 << 0)
43#define HEAP_PAGE_PRUNE_FREEZE (1 << 1)
44#define HEAP_PAGE_PRUNE_ALLOW_FAST_PATH (1 << 2)
45#define HEAP_PAGE_PRUNE_SET_VM (1 << 3)
46
52
53#define MaxLockTupleMode LockTupleExclusive
54
55/*
56 * Descriptor for heap table scans.
57 */
58typedef struct HeapScanDescData
59{
60 TableScanDescData rs_base; /* AM independent part of the descriptor */
61
62 /* state set up at initscan time */
63 BlockNumber rs_nblocks; /* total number of blocks in rel */
64 BlockNumber rs_startblock; /* block # to start at */
65 BlockNumber rs_numblocks; /* max number of blocks to scan */
66 /* rs_numblocks is usually InvalidBlockNumber, meaning "scan whole rel" */
67
68 /* scan current state */
69 bool rs_inited; /* false = scan not init'd yet */
70 OffsetNumber rs_coffset; /* current offset # in non-page-at-a-time mode */
71 BlockNumber rs_cblock; /* current block # in scan, if any */
72 Buffer rs_cbuf; /* current buffer in scan, if any */
73 /* NB: if rs_cbuf is not InvalidBuffer, we hold a pin on that buffer */
74
75 BufferAccessStrategy rs_strategy; /* access strategy for reads */
76
77 HeapTupleData rs_ctup; /* current tuple in scan, if any */
78
79 /* For scans that stream reads */
81
82 /*
83 * For sequential scans and TID range scans to stream reads. The read
84 * stream is allocated at the beginning of the scan and reset on rescan or
85 * when the scan direction changes. The scan direction is saved each time
86 * a new page is requested. If the scan direction changes from one page to
87 * the next, the read stream releases all previously pinned buffers and
88 * resets the prefetch block.
89 */
92
93 /*
94 * For parallel scans to store page allocation data. NULL when not
95 * performing a parallel scan.
96 */
98
99 /* Current heap block's corresponding page in the visibility map */
101
102 /* these fields only used in page-at-a-time mode and for bitmap scans */
103 uint32 rs_cindex; /* current tuple's index in vistuples */
104 uint32 rs_ntuples; /* number of visible tuples on page */
108
116
117/*
118 * Descriptor for fetches from heap via an index.
119 */
120typedef struct IndexFetchHeapData
121{
122 IndexFetchTableData xs_base; /* AM independent part of the descriptor */
123
124 /*
125 * Current heap buffer in scan (and its block number), if any. NB: if
126 * xs_blk is not InvalidBlockNumber, we hold a pin in xs_cbuf.
127 */
130
131 /* Current heap block's corresponding page in the visibility map */
134
135/* Result codes for HeapTupleSatisfiesVacuum */
136typedef enum
137{
138 HEAPTUPLE_DEAD, /* tuple is dead and deletable */
139 HEAPTUPLE_LIVE, /* tuple is live (committed, no deleter) */
140 HEAPTUPLE_RECENTLY_DEAD, /* tuple is dead, but not deletable yet */
141 HEAPTUPLE_INSERT_IN_PROGRESS, /* inserting xact is still in progress */
142 HEAPTUPLE_DELETE_IN_PROGRESS, /* deleting xact is still in progress */
144
145/*
146 * heap_prepare_freeze_tuple may request that heap_freeze_execute_prepared
147 * check any tuple's to-be-frozen xmin and/or xmax status using pg_xact
148 */
149#define HEAP_FREEZE_CHECK_XMIN_COMMITTED 0x01
150#define HEAP_FREEZE_CHECK_XMAX_ABORTED 0x02
151
152/* heap_prepare_freeze_tuple state describing how to freeze a tuple */
153typedef struct HeapTupleFreeze
154{
155 /* Fields describing how to process tuple */
160
161 /* xmin/xmax check flags */
163 /* Page offset number for tuple */
166
167/*
168 * State used by VACUUM to track the details of freezing all eligible tuples
169 * on a given heap page.
170 *
171 * VACUUM prepares freeze plans for each page via heap_prepare_freeze_tuple
172 * calls (every tuple with storage gets its own call). This page-level freeze
173 * state is updated across each call, which ultimately determines whether or
174 * not freezing the page is required.
175 *
176 * Aside from the basic question of whether or not freezing will go ahead, the
177 * state also tracks the oldest extant XID/MXID in the table as a whole, for
178 * the purposes of advancing relfrozenxid/relminmxid values in pg_class later
179 * on. Each heap_prepare_freeze_tuple call pushes NewRelfrozenXid and/or
180 * NewRelminMxid back as required to avoid unsafe final pg_class values. Any
181 * and all unfrozen XIDs or MXIDs that remain after VACUUM finishes _must_
182 * have values >= the final relfrozenxid/relminmxid values in pg_class. This
183 * includes XIDs that remain as MultiXact members from any tuple's xmax.
184 *
185 * When 'freeze_required' flag isn't set after all tuples are examined, the
186 * final choice on freezing is made by vacuumlazy.c. It can decide to trigger
187 * freezing based on whatever criteria it deems appropriate. However, it is
188 * recommended that vacuumlazy.c avoid early freezing when freezing does not
189 * enable setting the target page all-frozen in the visibility map afterwards.
190 */
191typedef struct HeapPageFreeze
192{
193 /* Is heap_prepare_freeze_tuple caller required to freeze page? */
195
196 /*
197 * "Freeze" NewRelfrozenXid/NewRelminMxid trackers.
198 *
199 * Trackers used when heap_freeze_execute_prepared freezes, or when there
200 * are zero freeze plans for a page. It is always valid for vacuumlazy.c
201 * to freeze any page, by definition. This even includes pages that have
202 * no tuples with storage to consider in the first place. That way the
203 * 'totally_frozen' results from heap_prepare_freeze_tuple can always be
204 * used in the same way, even when no freeze plans need to be executed to
205 * "freeze the page". Only the "freeze" path needs to consider the need
206 * to set pages all-frozen in the visibility map under this scheme.
207 *
208 * When we freeze a page, we generally freeze all XIDs < OldestXmin, only
209 * leaving behind XIDs that are ineligible for freezing, if any. And so
210 * you might wonder why these trackers are necessary at all; why should
211 * _any_ page that VACUUM freezes _ever_ be left with XIDs/MXIDs that
212 * ratchet back the top-level NewRelfrozenXid/NewRelminMxid trackers?
213 *
214 * It is useful to use a definition of "freeze the page" that does not
215 * overspecify how MultiXacts are affected. heap_prepare_freeze_tuple
216 * generally prefers to remove Multis eagerly, but lazy processing is used
217 * in cases where laziness allows VACUUM to avoid allocating a new Multi.
218 * The "freeze the page" trackers enable this flexibility.
219 */
222
223 /*
224 * Newest XID that this page's freeze actions will remove from tuple
225 * visibility metadata (currently xmin and/or xvac). It is used to derive
226 * the snapshot conflict horizon for a WAL record that freezes tuples. On
227 * a standby, we must not replay that change while any snapshot could
228 * still treat that XID as running.
229 *
230 * It's only used if we execute freeze plans for this page, so there is no
231 * corresponding "no freeze" tracker.
232 */
234
235 /*
236 * "No freeze" NewRelfrozenXid/NewRelminMxid trackers.
237 *
238 * These trackers are maintained in the same way as the trackers used when
239 * VACUUM scans a page that isn't cleanup locked. Both code paths are
240 * based on the same general idea (do less work for this page during the
241 * ongoing VACUUM, at the cost of having to accept older final values).
242 */
245
247
248
249/* 'reason' codes for heap_page_prune_and_freeze() */
250typedef enum
251{
252 PRUNE_ON_ACCESS, /* on-access pruning */
253 PRUNE_VACUUM_SCAN, /* VACUUM 1st heap pass */
254 PRUNE_VACUUM_CLEANUP, /* VACUUM 2nd heap pass */
256
257/*
258 * Input parameters to heap_page_prune_and_freeze()
259 */
260typedef struct PruneFreezeParams
261{
262 Relation relation; /* relation containing buffer to be pruned */
263 Buffer buffer; /* buffer to be pruned */
264
265 /*
266 * Callers should provide a pinned vmbuffer corresponding to the heap
267 * block in buffer. We will check for and repair any corruption in the VM
268 * and set the VM after pruning if the page is all-visible/all-frozen.
269 */
271
272 /*
273 * The reason pruning was performed. It is used to set the WAL record
274 * opcode which is used for debugging and analysis purposes.
275 */
277
278 /*
279 * Contains flag bits:
280 *
281 * HEAP_PAGE_PRUNE_MARK_UNUSED_NOW indicates that dead items can be set
282 * LP_UNUSED during pruning.
283 *
284 * HEAP_PAGE_PRUNE_FREEZE indicates that we will also freeze tuples.
285 */
287
288 /*
289 * vistest is used to distinguish whether tuples are DEAD or RECENTLY_DEAD
290 * (see heap_prune_satisfies_vacuum).
291 */
293
294 /*
295 * Contains the cutoffs used for freezing. They are required if the
296 * HEAP_PAGE_PRUNE_FREEZE option is set. cutoffs->OldestXmin is also used
297 * to determine if dead tuples are HEAPTUPLE_RECENTLY_DEAD or
298 * HEAPTUPLE_DEAD. Currently only vacuum passes in cutoffs. Vacuum
299 * calculates them once, at the beginning of vacuuming the relation.
300 */
303
304/*
305 * Per-page state returned by heap_page_prune_and_freeze()
306 */
307typedef struct PruneFreezeResult
308{
309 int ndeleted; /* Number of tuples deleted from the page */
310 int nnewlpdead; /* Number of newly LP_DEAD items */
311 int nfrozen; /* Number of tuples we froze */
312
313 /* Number of live and recently dead tuples on the page, after pruning */
316
317 /*
318 * Whether or not the page was newly set all-visible and all-frozen during
319 * phase I of vacuuming.
320 */
324
325 /*
326 * Whether or not the page makes rel truncation unsafe. This is set to
327 * 'true', even if the page contains LP_DEAD items. VACUUM will remove
328 * them before attempting to truncate.
329 */
330 bool hastup;
331
332 /*
333 * LP_DEAD items on the page after pruning. Includes existing LP_DEAD
334 * items.
335 */
339
340
341/* ----------------
342 * function prototypes for heap access method
343 *
344 * heap_create, heap_create_with_catalog, and heap_drop_with_catalog
345 * are declared in catalog/heap.h
346 * ----------------
347 */
348
349
350extern TableScanDesc heap_beginscan(Relation relation, Snapshot snapshot,
351 int nkeys, ScanKey key,
352 ParallelTableScanDesc parallel_scan,
353 uint32 flags);
357extern void heap_rescan(TableScanDesc sscan, ScanKey key, bool set_params,
358 bool allow_strat, bool allow_sync, bool allow_pagemode);
359extern void heap_endscan(TableScanDesc sscan);
362 ScanDirection direction, TupleTableSlot *slot);
366 ScanDirection direction,
367 TupleTableSlot *slot);
368extern bool heap_fetch(Relation relation, Snapshot snapshot,
369 HeapTuple tuple, Buffer *userbuf, bool keep_buf);
370
372
375extern void ReleaseBulkInsertStatePin(BulkInsertState bistate);
376
377extern void heap_insert(Relation relation, HeapTuple tup, CommandId cid,
379extern void heap_multi_insert(Relation relation, TupleTableSlot **slots,
380 int ntuples, CommandId cid, uint32 options,
381 BulkInsertState bistate);
382extern TM_Result heap_delete(Relation relation, const ItemPointerData *tid,
384 bool wait, TM_FailureData *tmfd);
385extern void heap_finish_speculative(Relation relation, const ItemPointerData *tid);
386extern void heap_abort_speculative(Relation relation, const ItemPointerData *tid);
390 Snapshot crosscheck, bool wait,
391 TM_FailureData *tmfd, LockTupleMode *lockmode,
393extern TM_Result heap_lock_tuple(Relation relation, HeapTuple tuple,
395 bool follow_updates,
396 Buffer *buffer, TM_FailureData *tmfd);
397
398extern bool heap_inplace_lock(Relation relation,
400 void (*release_callback) (void *), void *arg);
401extern void heap_inplace_update_and_unlock(Relation relation,
403 Buffer buffer);
404extern void heap_inplace_unlock(Relation relation,
405 HeapTuple oldtup, Buffer buffer);
407 const VacuumCutoffs *cutoffs,
408 HeapPageFreeze *pagefrz,
410
411extern void heap_pre_freeze_checks(Buffer buffer,
412 HeapTupleFreeze *tuples, int ntuples);
413extern void heap_freeze_prepared_tuples(Buffer buffer,
414 HeapTupleFreeze *tuples, int ntuples);
415extern bool heap_freeze_tuple(HeapTupleHeader tuple,
416 TransactionId relfrozenxid, TransactionId relminmxid,
417 TransactionId FreezeLimit, TransactionId MultiXactCutoff);
419 const VacuumCutoffs *cutoffs,
420 TransactionId *NoFreezePageRelfrozenXid,
421 MultiXactId *NoFreezePageRelminMxid);
423
424extern void simple_heap_insert(Relation relation, HeapTuple tup);
425extern void simple_heap_delete(Relation relation, const ItemPointerData *tid);
426extern void simple_heap_update(Relation relation, const ItemPointerData *otid,
428
431
432/* in heap/heapam_indexscan.c */
436extern bool heap_hot_search_buffer(ItemPointer tid, Relation relation,
437 Buffer buffer, Snapshot snapshot, HeapTuple heapTuple,
438 bool *all_dead, bool first_call);
439extern bool heapam_index_fetch_tuple(struct IndexFetchTableData *scan,
440 ItemPointer tid, Snapshot snapshot,
441 TupleTableSlot *slot, bool *heap_continue,
442 bool *all_dead);
443
444/* in heap/pruneheap.c */
445extern void heap_page_prune_opt(Relation relation, Buffer buffer,
446 Buffer *vmbuffer, bool rel_read_only);
452extern void heap_page_prune_execute(Buffer buffer, bool lp_truncate_only,
453 OffsetNumber *redirected, int nredirected,
454 OffsetNumber *nowdead, int ndead,
455 OffsetNumber *nowunused, int nunused);
457extern void log_heap_prune_and_freeze(Relation relation, Buffer buffer,
458 Buffer vmbuffer, uint8 vmflags,
460 bool cleanup_lock,
461 PruneReason reason,
462 HeapTupleFreeze *frozen, int nfrozen,
463 OffsetNumber *redirected, int nredirected,
464 OffsetNumber *dead, int ndead,
465 OffsetNumber *unused, int nunused);
466
467/* in heap/vacuumlazy.c */
468extern void heap_vacuum_rel(Relation rel,
469 const VacuumParams *params, BufferAccessStrategy bstrategy);
470#ifdef USE_ASSERT_CHECKING
472 GlobalVisState *vistest,
473 bool *all_frozen,
474 TransactionId *newest_live_xid,
476#endif
477
478/* in heap/heapam_visibility.c */
479extern bool HeapTupleSatisfiesVisibility(HeapTuple htup, Snapshot snapshot,
480 Buffer buffer);
482 Buffer buffer);
484 Buffer buffer);
487extern void HeapTupleSetHintBits(HeapTupleHeader tuple, Buffer buffer,
490extern bool HeapTupleIsSurelyDead(HeapTuple htup,
491 GlobalVisState *vistest);
492
493/*
494 * Some of the input/output to/from HeapTupleSatisfiesMVCCBatch() is passed
495 * via this struct, as otherwise the increased number of arguments to
496 * HeapTupleSatisfiesMVCCBatch() leads to on-stack argument passing on x86-64,
497 * which causes a small regression.
498 */
504
505extern int HeapTupleSatisfiesMVCCBatch(Snapshot snapshot, Buffer buffer,
506 int ntups,
509
510/*
511 * To avoid leaking too much knowledge about reorderbuffer implementation
512 * details this is implemented in reorderbuffer.c not heapam_visibility.c
513 */
514struct HTAB;
516 Snapshot snapshot,
517 HeapTuple htup,
518 Buffer buffer,
519 CommandId *cmin, CommandId *cmax);
520extern void HeapCheckForSerializableConflictOut(bool visible, Relation relation, HeapTuple tuple,
521 Buffer buffer, Snapshot snapshot);
522
523/*
524 * heap_execute_freeze_tuple
525 * Execute the prepared freezing of a tuple with caller's freeze plan.
526 *
527 * Caller is responsible for ensuring that no other backend can access the
528 * storage underlying this tuple, either by holding an exclusive lock on the
529 * buffer containing it (which is what lazy VACUUM does), or by having it be
530 * in private storage (which is what CLUSTER and friends do).
531 */
532static inline void
534{
535 HeapTupleHeaderSetXmax(tuple, frz->xmax);
536
537 if (frz->frzflags & XLH_FREEZE_XVAC)
539
540 if (frz->frzflags & XLH_INVALID_XVAC)
542
543 tuple->t_infomask = frz->t_infomask;
544 tuple->t_infomask2 = frz->t_infomask2;
545}
546
547#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:622
TransactionId MultiXactId
Definition c.h:746
uint16_t uint16
Definition c.h:623
uint32_t uint32
Definition c.h:624
uint32 CommandId
Definition c.h:750
uint32 TransactionId
Definition c.h:736
Datum arg
Definition elog.c:1323
void simple_heap_update(Relation relation, const ItemPointerData *otid, HeapTuple tup, TU_UpdateIndexes *update_indexes)
Definition heapam.c:4450
void heapam_index_fetch_end(IndexFetchTableData *scan)
bool heap_prepare_freeze_tuple(HeapTupleHeader tuple, const VacuumCutoffs *cutoffs, HeapPageFreeze *pagefrz, HeapTupleFreeze *frz, bool *totally_frozen)
bool heap_inplace_lock(Relation relation, HeapTuple oldtup_ptr, Buffer buffer, void(*release_callback)(void *), void *arg)
Definition heapam.c:6332
bool heap_fetch(Relation relation, Snapshot snapshot, HeapTuple tuple, Buffer *userbuf, bool keep_buf)
Definition heapam.c:1684
void heap_page_prune_opt(Relation relation, Buffer buffer, Buffer *vmbuffer, bool rel_read_only)
Definition pruneheap.c:271
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:107
void heap_get_root_tuples(Page page, OffsetNumber *root_offsets)
Definition pruneheap.c:2289
void heap_insert(Relation relation, HeapTuple tup, CommandId cid, uint32 options, BulkInsertState bistate)
Definition heapam.c:2004
void heap_finish_speculative(Relation relation, const ItemPointerData *tid)
Definition heapam.c:6063
HTSV_Result
Definition heapam.h:137
@ HEAPTUPLE_RECENTLY_DEAD
Definition heapam.h:140
@ HEAPTUPLE_INSERT_IN_PROGRESS
Definition heapam.h:141
@ HEAPTUPLE_LIVE
Definition heapam.h:139
@ HEAPTUPLE_DELETE_IN_PROGRESS
Definition heapam.h:142
@ HEAPTUPLE_DEAD
Definition heapam.h:138
bool heap_getnextslot(TableScanDesc sscan, ScanDirection direction, TupleTableSlot *slot)
Definition heapam.c:1474
void heap_page_prune_and_freeze(PruneFreezeParams *params, PruneFreezeResult *presult, OffsetNumber *off_loc, TransactionId *new_relfrozen_xid, MultiXactId *new_relmin_mxid)
Definition pruneheap.c:1090
void heap_endscan(TableScanDesc sscan)
Definition heapam.c:1390
void heap_rescan(TableScanDesc sscan, ScanKey key, bool set_params, bool allow_strat, bool allow_sync, bool allow_pagemode)
Definition heapam.c:1331
void heap_inplace_unlock(Relation relation, HeapTuple oldtup, Buffer buffer)
Definition heapam.c:6610
struct BitmapHeapScanDescData * BitmapHeapScanDesc
Definition heapam.h:115
bool heap_tuple_needs_eventual_freeze(HeapTupleHeader tuple)
Definition heapam.c:7791
bool heapam_index_fetch_tuple(struct IndexFetchTableData *scan, ItemPointer tid, Snapshot snapshot, TupleTableSlot *slot, bool *heap_continue, bool *all_dead)
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:2561
bool heap_freeze_tuple(HeapTupleHeader tuple, TransactionId relfrozenxid, TransactionId relminmxid, TransactionId FreezeLimit, TransactionId MultiXactCutoff)
Definition heapam.c:7382
void heap_inplace_update_and_unlock(Relation relation, HeapTuple oldtup, HeapTuple tuple, Buffer buffer)
Definition heapam.c:6470
void ReleaseBulkInsertStatePin(BulkInsertState bistate)
Definition heapam.c:1966
bool HeapTupleIsSurelyDead(HeapTuple htup, GlobalVisState *vistest)
HeapTuple heap_getnext(TableScanDesc sscan, ScanDirection direction)
Definition heapam.c:1435
bool heap_hot_search_buffer(ItemPointer tid, Relation relation, Buffer buffer, Snapshot snapshot, HeapTuple heapTuple, bool *all_dead, bool first_call)
void heap_freeze_prepared_tuples(Buffer buffer, HeapTupleFreeze *tuples, int ntuples)
Definition heapam.c:7360
static void heap_execute_freeze_tuple(HeapTupleHeader tuple, HeapTupleFreeze *frz)
Definition heapam.h:533
bool heap_tuple_should_freeze(HeapTupleHeader tuple, const VacuumCutoffs *cutoffs, TransactionId *NoFreezePageRelfrozenXid, MultiXactId *NoFreezePageRelminMxid)
bool heap_getnextslot_tidrange(TableScanDesc sscan, ScanDirection direction, TupleTableSlot *slot)
Definition heapam.c:1577
void heap_set_tidrange(TableScanDesc sscan, ItemPointer mintid, ItemPointer maxtid)
Definition heapam.c:1504
HTSV_Result HeapTupleSatisfiesVacuum(HeapTuple htup, TransactionId OldestXmin, Buffer buffer)
void heap_abort_speculative(Relation relation, const ItemPointerData *tid)
Definition heapam.c:6150
void heap_multi_insert(Relation relation, TupleTableSlot **slots, int ntuples, CommandId cid, uint32 options, BulkInsertState bistate)
Definition heapam.c:2282
TableScanDesc heap_beginscan(Relation relation, Snapshot snapshot, int nkeys, ScanKey key, ParallelTableScanDesc parallel_scan, uint32 flags)
Definition heapam.c:1167
void heap_prepare_pagescan(TableScanDesc sscan)
Definition heapam.c:618
int HeapTupleSatisfiesMVCCBatch(Snapshot snapshot, Buffer buffer, int ntups, BatchMVCCState *batchmvcc, OffsetNumber *vistuples_dense)
void simple_heap_insert(Relation relation, HeapTuple tup)
Definition heapam.c:2659
void heap_vacuum_rel(Relation rel, const VacuumParams *params, BufferAccessStrategy bstrategy)
Definition vacuumlazy.c:624
void simple_heap_delete(Relation relation, const ItemPointerData *tid)
Definition heapam.c:3153
IndexFetchTableData * heapam_index_fetch_begin(Relation rel, uint32 flags)
void heapam_index_fetch_reset(IndexFetchTableData *scan)
TransactionId heap_index_delete_tuples(Relation rel, TM_IndexDeleteOp *delstate)
Definition heapam.c:8099
bool HeapTupleHeaderIsOnlyLocked(HeapTupleHeader tuple)
PruneReason
Definition heapam.h:251
@ PRUNE_VACUUM_CLEANUP
Definition heapam.h:254
@ PRUNE_ON_ACCESS
Definition heapam.h:252
@ PRUNE_VACUUM_SCAN
Definition heapam.h:253
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:2065
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:4539
TM_Result HeapTupleSatisfiesUpdate(HeapTuple htup, CommandId curcid, Buffer buffer)
struct BulkInsertStateData * BulkInsertState
Definition heapam.h:47
void heap_get_latest_tid(TableScanDesc sscan, ItemPointer tid)
Definition heapam.c:1793
void heap_setscanlimits(TableScanDesc sscan, BlockNumber startBlk, BlockNumber numBlks)
Definition heapam.c:502
void HeapCheckForSerializableConflictOut(bool visible, Relation relation, HeapTuple tuple, Buffer buffer, Snapshot snapshot)
Definition heapam.c:9183
TM_Result heap_update(Relation relation, const ItemPointerData *otid, HeapTuple newtup, CommandId cid, uint32 options, Snapshot crosscheck, bool wait, TM_FailureData *tmfd, LockTupleMode *lockmode, TU_UpdateIndexes *update_indexes)
void FreeBulkInsertState(BulkInsertState)
Definition heapam.c:1954
void heap_pre_freeze_checks(Buffer buffer, HeapTupleFreeze *tuples, int ntuples)
Definition heapam.c:7307
BulkInsertState GetBulkInsertState(void)
Definition heapam.c:1937
TM_Result heap_delete(Relation relation, const ItemPointerData *tid, CommandId cid, uint32 options, Snapshot crosscheck, bool wait, TM_FailureData *tmfd)
Definition heapam.c:2717
#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 char buf[DEFAULT_XLOG_SEG_SIZE]
static int fb(int x)
ScanDirection
Definition sdir.h:25
static HTAB * tuplecid_data
Definition snapmgr.c:163
bool visible[MaxHeapTuplesPerPage]
Definition heapam.h:502
HeapTupleData tuples[MaxHeapTuplesPerPage]
Definition heapam.h:501
HeapScanDescData rs_heap_base
Definition heapam.h:111
MultiXactId NoFreezePageRelminMxid
Definition heapam.h:244
TransactionId FreezePageConflictXid
Definition heapam.h:233
TransactionId FreezePageRelfrozenXid
Definition heapam.h:220
bool freeze_required
Definition heapam.h:194
MultiXactId FreezePageRelminMxid
Definition heapam.h:221
TransactionId NoFreezePageRelfrozenXid
Definition heapam.h:243
Buffer rs_vmbuffer
Definition heapam.h:100
BufferAccessStrategy rs_strategy
Definition heapam.h:75
ScanDirection rs_dir
Definition heapam.h:90
uint32 rs_ntuples
Definition heapam.h:104
OffsetNumber rs_coffset
Definition heapam.h:70
Buffer rs_cbuf
Definition heapam.h:72
ParallelBlockTableScanWorkerData * rs_parallelworkerdata
Definition heapam.h:97
BlockNumber rs_startblock
Definition heapam.h:64
HeapTupleData rs_ctup
Definition heapam.h:77
OffsetNumber rs_vistuples[MaxHeapTuplesPerPage]
Definition heapam.h:105
BlockNumber rs_numblocks
Definition heapam.h:65
BlockNumber rs_nblocks
Definition heapam.h:63
ReadStream * rs_read_stream
Definition heapam.h:80
uint32 rs_cindex
Definition heapam.h:103
BlockNumber rs_prefetch_block
Definition heapam.h:91
BlockNumber rs_cblock
Definition heapam.h:71
TableScanDescData rs_base
Definition heapam.h:60
uint8 frzflags
Definition heapam.h:159
uint16 t_infomask2
Definition heapam.h:157
TransactionId xmax
Definition heapam.h:156
OffsetNumber offset
Definition heapam.h:164
uint8 checkflags
Definition heapam.h:162
uint16 t_infomask
Definition heapam.h:158
IndexFetchTableData xs_base
Definition heapam.h:122
Buffer xs_vmbuffer
Definition heapam.h:132
BlockNumber xs_blk
Definition heapam.h:129
PruneReason reason
Definition heapam.h:276
VacuumCutoffs * cutoffs
Definition heapam.h:301
GlobalVisState * vistest
Definition heapam.h:292
Relation relation
Definition heapam.h:262
Buffer vmbuffer
Definition heapam.h:270
bool newly_all_visible_frozen
Definition heapam.h:322
int recently_dead_tuples
Definition heapam.h:315
bool newly_all_frozen
Definition heapam.h:323
OffsetNumber deadoffsets[MaxHeapTuplesPerPage]
Definition heapam.h:337
bool newly_all_visible
Definition heapam.h:321
TU_UpdateIndexes
Definition tableam.h:133
TM_Result
Definition tableam.h:95
#define FrozenTransactionId
Definition transam.h:33
#define InvalidTransactionId
Definition transam.h:31