| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| #ifndef HEAPAM_H |
| #define HEAPAM_H |
|
|
| #include "access/relation.h" |
| #include "access/relscan.h" |
| #include "access/sdir.h" |
| #include "access/skey.h" |
| #include "access/table.h" |
| #include "access/tableam.h" |
| #include "nodes/lockoptions.h" |
| #include "nodes/primnodes.h" |
| #include "storage/bufpage.h" |
| #include "storage/dsm.h" |
| #include "storage/lockdefs.h" |
| #include "storage/read_stream.h" |
| #include "storage/shm_toc.h" |
| #include "utils/relcache.h" |
| #include "utils/snapshot.h" |
|
|
|
|
| |
| #define HEAP_INSERT_SKIP_FSM TABLE_INSERT_SKIP_FSM |
| #define HEAP_INSERT_FROZEN TABLE_INSERT_FROZEN |
| #define HEAP_INSERT_NO_LOGICAL TABLE_INSERT_NO_LOGICAL |
| #define HEAP_INSERT_SPECULATIVE 0x0010 |
|
|
| |
| #define HEAP_PAGE_PRUNE_MARK_UNUSED_NOW (1 << 0) |
| #define HEAP_PAGE_PRUNE_FREEZE (1 << 1) |
|
|
| typedef struct BulkInsertStateData *BulkInsertState; |
| struct TupleTableSlot; |
| struct VacuumCutoffs; |
|
|
| #define MaxLockTupleMode LockTupleExclusive |
|
|
| |
| |
| |
| typedef struct HeapScanDescData |
| { |
| TableScanDescData rs_base; |
|
|
| |
| BlockNumber rs_nblocks; |
| BlockNumber rs_startblock; |
| BlockNumber rs_numblocks; |
| |
|
|
| |
| bool rs_inited; |
| OffsetNumber rs_coffset; |
| BlockNumber rs_cblock; |
| Buffer rs_cbuf; |
| |
|
|
| BufferAccessStrategy rs_strategy; |
|
|
| HeapTupleData rs_ctup; |
|
|
| |
| ReadStream *rs_read_stream; |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| ScanDirection rs_dir; |
| BlockNumber rs_prefetch_block; |
|
|
| |
| |
| |
| |
| ParallelBlockTableScanWorkerData *rs_parallelworkerdata; |
|
|
| |
| |
| |
| |
| |
| |
| |
| Buffer rs_vmbuffer; |
| int rs_empty_tuples_pending; |
|
|
| |
| int rs_cindex; |
| int rs_ntuples; |
| OffsetNumber rs_vistuples[MaxHeapTuplesPerPage]; |
| } HeapScanDescData; |
| typedef struct HeapScanDescData *HeapScanDesc; |
|
|
| |
| |
| |
| typedef struct IndexFetchHeapData |
| { |
| IndexFetchTableData xs_base; |
|
|
| Buffer xs_cbuf; |
| |
| } IndexFetchHeapData; |
|
|
| |
| typedef enum |
| { |
| HEAPTUPLE_DEAD, |
| HEAPTUPLE_LIVE, |
| HEAPTUPLE_RECENTLY_DEAD, |
| HEAPTUPLE_INSERT_IN_PROGRESS, |
| HEAPTUPLE_DELETE_IN_PROGRESS, |
| } HTSV_Result; |
|
|
| |
| |
| |
| |
| #define HEAP_FREEZE_CHECK_XMIN_COMMITTED 0x01 |
| #define HEAP_FREEZE_CHECK_XMAX_ABORTED 0x02 |
|
|
| |
| typedef struct HeapTupleFreeze |
| { |
| |
| TransactionId xmax; |
| uint16 t_infomask2; |
| uint16 t_infomask; |
| uint8 frzflags; |
|
|
| |
| uint8 checkflags; |
| |
| OffsetNumber offset; |
| } HeapTupleFreeze; |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| typedef struct HeapPageFreeze |
| { |
| |
| bool freeze_required; |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| TransactionId FreezePageRelfrozenXid; |
| MultiXactId FreezePageRelminMxid; |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| TransactionId NoFreezePageRelfrozenXid; |
| MultiXactId NoFreezePageRelminMxid; |
|
|
| } HeapPageFreeze; |
|
|
| |
| |
| |
| typedef struct PruneFreezeResult |
| { |
| int ndeleted; |
| int nnewlpdead; |
| int nfrozen; |
|
|
| |
| int live_tuples; |
| int recently_dead_tuples; |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| bool all_visible; |
| bool all_frozen; |
| TransactionId vm_conflict_horizon; |
|
|
| |
| |
| |
| |
| |
| bool hastup; |
|
|
| |
| |
| |
| |
| int lpdead_items; |
| OffsetNumber deadoffsets[MaxHeapTuplesPerPage]; |
| } PruneFreezeResult; |
|
|
| |
| typedef enum |
| { |
| PRUNE_ON_ACCESS, |
| PRUNE_VACUUM_SCAN, |
| PRUNE_VACUUM_CLEANUP, |
| } PruneReason; |
|
|
| |
| |
| |
| |
| |
| |
| |
|
|
|
|
| |
| |
| |
| |
| #define HeapScanIsValid(scan) PointerIsValid(scan) |
|
|
| extern TableScanDesc heap_beginscan(Relation relation, Snapshot snapshot, |
| int nkeys, ScanKey key, |
| ParallelTableScanDesc parallel_scan, |
| uint32 flags); |
| extern void heap_setscanlimits(TableScanDesc sscan, BlockNumber startBlk, |
| BlockNumber numBlks); |
| extern void heap_prepare_pagescan(TableScanDesc sscan); |
| extern void heap_rescan(TableScanDesc sscan, ScanKey key, bool set_params, |
| bool allow_strat, bool allow_sync, bool allow_pagemode); |
| extern void heap_endscan(TableScanDesc sscan); |
| extern HeapTuple heap_getnext(TableScanDesc sscan, ScanDirection direction); |
| extern bool heap_getnextslot(TableScanDesc sscan, |
| ScanDirection direction, struct TupleTableSlot *slot); |
| extern void heap_set_tidrange(TableScanDesc sscan, ItemPointer mintid, |
| ItemPointer maxtid); |
| extern bool heap_getnextslot_tidrange(TableScanDesc sscan, |
| ScanDirection direction, |
| TupleTableSlot *slot); |
| extern bool heap_fetch(Relation relation, Snapshot snapshot, |
| HeapTuple tuple, Buffer *userbuf, bool keep_buf); |
| extern bool heap_hot_search_buffer(ItemPointer tid, Relation relation, |
| Buffer buffer, Snapshot snapshot, HeapTuple heapTuple, |
| bool *all_dead, bool first_call); |
|
|
| extern void heap_get_latest_tid(TableScanDesc sscan, ItemPointer tid); |
|
|
| extern BulkInsertState GetBulkInsertState(void); |
| extern void FreeBulkInsertState(BulkInsertState); |
| extern void ReleaseBulkInsertStatePin(BulkInsertState bistate); |
|
|
| extern void heap_insert(Relation relation, HeapTuple tup, CommandId cid, |
| int options, BulkInsertState bistate); |
| extern void heap_multi_insert(Relation relation, struct TupleTableSlot **slots, |
| int ntuples, CommandId cid, int options, |
| BulkInsertState bistate); |
| extern TM_Result heap_delete(Relation relation, ItemPointer tid, |
| CommandId cid, Snapshot crosscheck, bool wait, |
| struct TM_FailureData *tmfd, bool changingPart); |
| extern void heap_finish_speculative(Relation relation, ItemPointer tid); |
| extern void heap_abort_speculative(Relation relation, ItemPointer tid); |
| extern TM_Result heap_update(Relation relation, ItemPointer otid, |
| HeapTuple newtup, |
| CommandId cid, Snapshot crosscheck, bool wait, |
| struct TM_FailureData *tmfd, LockTupleMode *lockmode, |
| TU_UpdateIndexes *update_indexes); |
| extern TM_Result heap_lock_tuple(Relation relation, HeapTuple tuple, |
| CommandId cid, LockTupleMode mode, LockWaitPolicy wait_policy, |
| bool follow_updates, |
| Buffer *buffer, struct TM_FailureData *tmfd); |
|
|
| extern bool heap_inplace_lock(Relation relation, |
| HeapTuple oldtup_ptr, Buffer buffer, |
| void (*release_callback) (void *), void *arg); |
| extern void heap_inplace_update_and_unlock(Relation relation, |
| HeapTuple oldtup, HeapTuple tuple, |
| Buffer buffer); |
| extern void heap_inplace_unlock(Relation relation, |
| HeapTuple oldtup, Buffer buffer); |
| extern void heap_inplace_update(Relation relation, HeapTuple tuple); |
| extern bool heap_prepare_freeze_tuple(HeapTupleHeader tuple, |
| const struct VacuumCutoffs *cutoffs, |
| HeapPageFreeze *pagefrz, |
| HeapTupleFreeze *frz, bool *totally_frozen); |
|
|
| extern void heap_pre_freeze_checks(Buffer buffer, |
| HeapTupleFreeze *tuples, int ntuples); |
| extern void heap_freeze_prepared_tuples(Buffer buffer, |
| HeapTupleFreeze *tuples, int ntuples); |
| extern bool heap_freeze_tuple(HeapTupleHeader tuple, |
| TransactionId relfrozenxid, TransactionId relminmxid, |
| TransactionId FreezeLimit, TransactionId MultiXactCutoff); |
| extern bool heap_tuple_should_freeze(HeapTupleHeader tuple, |
| const struct VacuumCutoffs *cutoffs, |
| TransactionId *NoFreezePageRelfrozenXid, |
| MultiXactId *NoFreezePageRelminMxid); |
| extern bool heap_tuple_needs_eventual_freeze(HeapTupleHeader tuple); |
|
|
| extern void simple_heap_insert(Relation relation, HeapTuple tup); |
| extern void simple_heap_delete(Relation relation, ItemPointer tid); |
| extern void simple_heap_update(Relation relation, ItemPointer otid, |
| HeapTuple tup, TU_UpdateIndexes *update_indexes); |
|
|
| extern TransactionId heap_index_delete_tuples(Relation rel, |
| TM_IndexDeleteOp *delstate); |
|
|
| |
| struct GlobalVisState; |
| extern void heap_page_prune_opt(Relation relation, Buffer buffer); |
| extern void heap_page_prune_and_freeze(Relation relation, Buffer buffer, |
| struct GlobalVisState *vistest, |
| int options, |
| struct VacuumCutoffs *cutoffs, |
| PruneFreezeResult *presult, |
| PruneReason reason, |
| OffsetNumber *off_loc, |
| TransactionId *new_relfrozen_xid, |
| MultiXactId *new_relmin_mxid); |
| extern void heap_page_prune_execute(Buffer buffer, bool lp_truncate_only, |
| OffsetNumber *redirected, int nredirected, |
| OffsetNumber *nowdead, int ndead, |
| OffsetNumber *nowunused, int nunused); |
| extern void heap_get_root_tuples(Page page, OffsetNumber *root_offsets); |
| extern void log_heap_prune_and_freeze(Relation relation, Buffer buffer, |
| TransactionId conflict_xid, |
| bool cleanup_lock, |
| PruneReason reason, |
| HeapTupleFreeze *frozen, int nfrozen, |
| OffsetNumber *redirected, int nredirected, |
| OffsetNumber *dead, int ndead, |
| OffsetNumber *unused, int nunused); |
|
|
| |
| struct VacuumParams; |
| extern void heap_vacuum_rel(Relation rel, |
| struct VacuumParams *params, BufferAccessStrategy bstrategy); |
|
|
| |
| extern bool HeapTupleSatisfiesVisibility(HeapTuple htup, Snapshot snapshot, |
| Buffer buffer); |
| extern TM_Result HeapTupleSatisfiesUpdate(HeapTuple htup, CommandId curcid, |
| Buffer buffer); |
| extern HTSV_Result HeapTupleSatisfiesVacuum(HeapTuple htup, TransactionId OldestXmin, |
| Buffer buffer); |
| extern HTSV_Result HeapTupleSatisfiesVacuumHorizon(HeapTuple htup, Buffer buffer, |
| TransactionId *dead_after); |
| extern void HeapTupleSetHintBits(HeapTupleHeader tuple, Buffer buffer, |
| uint16 infomask, TransactionId xid); |
| extern bool HeapTupleHeaderIsOnlyLocked(HeapTupleHeader tuple); |
| extern bool HeapTupleIsSurelyDead(HeapTuple htup, |
| struct GlobalVisState *vistest); |
|
|
| |
| |
| |
| |
| struct HTAB; |
| extern bool ResolveCminCmaxDuringDecoding(struct HTAB *tuplecid_data, |
| Snapshot snapshot, |
| HeapTuple htup, |
| Buffer buffer, |
| CommandId *cmin, CommandId *cmax); |
| extern void HeapCheckForSerializableConflictOut(bool visible, Relation relation, HeapTuple tuple, |
| Buffer buffer, Snapshot snapshot); |
|
|
| #endif |
|
|