gooderp18绿色标准版
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

222 行
8.5KB

  1. /*-------------------------------------------------------------------------
  2. *
  3. * heapam.h
  4. * POSTGRES heap access method definitions.
  5. *
  6. *
  7. * Portions Copyright (c) 1996-2019, 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. #include "access/relation.h" /* for backward compatibility */
  17. #include "access/relscan.h"
  18. #include "access/sdir.h"
  19. #include "access/skey.h"
  20. #include "access/table.h" /* for backward compatibility */
  21. #include "access/tableam.h"
  22. #include "nodes/lockoptions.h"
  23. #include "nodes/primnodes.h"
  24. #include "storage/bufpage.h"
  25. #include "storage/lockdefs.h"
  26. #include "utils/relcache.h"
  27. #include "utils/snapshot.h"
  28. /* "options" flag bits for heap_insert */
  29. #define HEAP_INSERT_SKIP_WAL TABLE_INSERT_SKIP_WAL
  30. #define HEAP_INSERT_SKIP_FSM TABLE_INSERT_SKIP_FSM
  31. #define HEAP_INSERT_FROZEN TABLE_INSERT_FROZEN
  32. #define HEAP_INSERT_NO_LOGICAL TABLE_INSERT_NO_LOGICAL
  33. #define HEAP_INSERT_SPECULATIVE 0x0010
  34. typedef struct BulkInsertStateData *BulkInsertState;
  35. struct TupleTableSlot;
  36. #define MaxLockTupleMode LockTupleExclusive
  37. /*
  38. * Descriptor for heap table scans.
  39. */
  40. typedef struct HeapScanDescData
  41. {
  42. TableScanDescData rs_base; /* AM independent part of the descriptor */
  43. /* state set up at initscan time */
  44. BlockNumber rs_nblocks; /* total number of blocks in rel */
  45. BlockNumber rs_startblock; /* block # to start at */
  46. BlockNumber rs_numblocks; /* max number of blocks to scan */
  47. /* rs_numblocks is usually InvalidBlockNumber, meaning "scan whole rel" */
  48. /* scan current state */
  49. bool rs_inited; /* false = scan not init'd yet */
  50. BlockNumber rs_cblock; /* current block # in scan, if any */
  51. Buffer rs_cbuf; /* current buffer in scan, if any */
  52. /* NB: if rs_cbuf is not InvalidBuffer, we hold a pin on that buffer */
  53. /* rs_numblocks is usually InvalidBlockNumber, meaning "scan whole rel" */
  54. BufferAccessStrategy rs_strategy; /* access strategy for reads */
  55. HeapTupleData rs_ctup; /* current tuple in scan, if any */
  56. /* these fields only used in page-at-a-time mode and for bitmap scans */
  57. int rs_cindex; /* current tuple's index in vistuples */
  58. int rs_ntuples; /* number of visible tuples on page */
  59. OffsetNumber rs_vistuples[MaxHeapTuplesPerPage]; /* their offsets */
  60. } HeapScanDescData;
  61. typedef struct HeapScanDescData *HeapScanDesc;
  62. /*
  63. * Descriptor for fetches from heap via an index.
  64. */
  65. typedef struct IndexFetchHeapData
  66. {
  67. IndexFetchTableData xs_base; /* AM independent part of the descriptor */
  68. Buffer xs_cbuf; /* current heap buffer in scan, if any */
  69. /* NB: if xs_cbuf is not InvalidBuffer, we hold a pin on that buffer */
  70. } IndexFetchHeapData;
  71. /* Result codes for HeapTupleSatisfiesVacuum */
  72. typedef enum
  73. {
  74. HEAPTUPLE_DEAD, /* tuple is dead and deletable */
  75. HEAPTUPLE_LIVE, /* tuple is live (committed, no deleter) */
  76. HEAPTUPLE_RECENTLY_DEAD, /* tuple is dead, but not deletable yet */
  77. HEAPTUPLE_INSERT_IN_PROGRESS, /* inserting xact is still in progress */
  78. HEAPTUPLE_DELETE_IN_PROGRESS /* deleting xact is still in progress */
  79. } HTSV_Result;
  80. /* ----------------
  81. * function prototypes for heap access method
  82. *
  83. * heap_create, heap_create_with_catalog, and heap_drop_with_catalog
  84. * are declared in catalog/heap.h
  85. * ----------------
  86. */
  87. /*
  88. * HeapScanIsValid
  89. * True iff the heap scan is valid.
  90. */
  91. #define HeapScanIsValid(scan) PointerIsValid(scan)
  92. extern TableScanDesc heap_beginscan(Relation relation, Snapshot snapshot,
  93. int nkeys, ScanKey key,
  94. ParallelTableScanDesc parallel_scan,
  95. uint32 flags);
  96. extern void heap_setscanlimits(TableScanDesc scan, BlockNumber startBlk,
  97. BlockNumber endBlk);
  98. extern void heapgetpage(TableScanDesc scan, BlockNumber page);
  99. extern void heap_rescan(TableScanDesc scan, ScanKey key, bool set_params,
  100. bool allow_strat, bool allow_sync, bool allow_pagemode);
  101. extern void heap_endscan(TableScanDesc scan);
  102. extern HeapTuple heap_getnext(TableScanDesc scan, ScanDirection direction);
  103. extern bool heap_getnextslot(TableScanDesc sscan,
  104. ScanDirection direction, struct TupleTableSlot *slot);
  105. extern bool heap_fetch(Relation relation, Snapshot snapshot,
  106. HeapTuple tuple, Buffer *userbuf);
  107. extern bool heap_hot_search_buffer(ItemPointer tid, Relation relation,
  108. Buffer buffer, Snapshot snapshot, HeapTuple heapTuple,
  109. bool *all_dead, bool first_call);
  110. extern void heap_get_latest_tid(TableScanDesc scan, ItemPointer tid);
  111. extern void setLastTid(const ItemPointer tid);
  112. extern BulkInsertState GetBulkInsertState(void);
  113. extern void FreeBulkInsertState(BulkInsertState);
  114. extern void ReleaseBulkInsertStatePin(BulkInsertState bistate);
  115. extern void heap_insert(Relation relation, HeapTuple tup, CommandId cid,
  116. int options, BulkInsertState bistate);
  117. extern void heap_multi_insert(Relation relation, struct TupleTableSlot **slots,
  118. int ntuples, CommandId cid, int options,
  119. BulkInsertState bistate);
  120. extern TM_Result heap_delete(Relation relation, ItemPointer tid,
  121. CommandId cid, Snapshot crosscheck, bool wait,
  122. struct TM_FailureData *tmfd, bool changingPart);
  123. extern void heap_finish_speculative(Relation relation, ItemPointer tid);
  124. extern void heap_abort_speculative(Relation relation, ItemPointer tid);
  125. extern TM_Result heap_update(Relation relation, ItemPointer otid,
  126. HeapTuple newtup,
  127. CommandId cid, Snapshot crosscheck, bool wait,
  128. struct TM_FailureData *tmfd, LockTupleMode *lockmode);
  129. extern TM_Result heap_lock_tuple(Relation relation, HeapTuple tuple,
  130. CommandId cid, LockTupleMode mode, LockWaitPolicy wait_policy,
  131. bool follow_update,
  132. Buffer *buffer, struct TM_FailureData *tmfd);
  133. extern void heap_inplace_update(Relation relation, HeapTuple tuple);
  134. extern bool heap_freeze_tuple(HeapTupleHeader tuple,
  135. TransactionId relfrozenxid, TransactionId relminmxid,
  136. TransactionId cutoff_xid, TransactionId cutoff_multi);
  137. extern bool heap_tuple_needs_freeze(HeapTupleHeader tuple, TransactionId cutoff_xid,
  138. MultiXactId cutoff_multi, Buffer buf);
  139. extern bool heap_tuple_needs_eventual_freeze(HeapTupleHeader tuple);
  140. extern void simple_heap_insert(Relation relation, HeapTuple tup);
  141. extern void simple_heap_delete(Relation relation, ItemPointer tid);
  142. extern void simple_heap_update(Relation relation, ItemPointer otid,
  143. HeapTuple tup);
  144. extern void heap_sync(Relation relation);
  145. extern TransactionId heap_compute_xid_horizon_for_tuples(Relation rel,
  146. ItemPointerData *items,
  147. int nitems);
  148. /* in heap/pruneheap.c */
  149. extern void heap_page_prune_opt(Relation relation, Buffer buffer);
  150. extern int heap_page_prune(Relation relation, Buffer buffer,
  151. TransactionId OldestXmin,
  152. bool report_stats, TransactionId *latestRemovedXid);
  153. extern void heap_page_prune_execute(Buffer buffer,
  154. OffsetNumber *redirected, int nredirected,
  155. OffsetNumber *nowdead, int ndead,
  156. OffsetNumber *nowunused, int nunused);
  157. extern void heap_get_root_tuples(Page page, OffsetNumber *root_offsets);
  158. /* in heap/syncscan.c */
  159. extern void ss_report_location(Relation rel, BlockNumber location);
  160. extern BlockNumber ss_get_location(Relation rel, BlockNumber relnblocks);
  161. extern void SyncScanShmemInit(void);
  162. extern Size SyncScanShmemSize(void);
  163. /* in heap/vacuumlazy.c */
  164. struct VacuumParams;
  165. extern void heap_vacuum_rel(Relation onerel,
  166. struct VacuumParams *params, BufferAccessStrategy bstrategy);
  167. /* in heap/heapam_visibility.c */
  168. extern bool HeapTupleSatisfiesVisibility(HeapTuple stup, Snapshot snapshot,
  169. Buffer buffer);
  170. extern TM_Result HeapTupleSatisfiesUpdate(HeapTuple stup, CommandId curcid,
  171. Buffer buffer);
  172. extern HTSV_Result HeapTupleSatisfiesVacuum(HeapTuple stup, TransactionId OldestXmin,
  173. Buffer buffer);
  174. extern void HeapTupleSetHintBits(HeapTupleHeader tuple, Buffer buffer,
  175. uint16 infomask, TransactionId xid);
  176. extern bool HeapTupleHeaderIsOnlyLocked(HeapTupleHeader tuple);
  177. extern bool XidInMVCCSnapshot(TransactionId xid, Snapshot snapshot);
  178. extern bool HeapTupleIsSurelyDead(HeapTuple htup, TransactionId OldestXmin);
  179. /*
  180. * To avoid leaking too much knowledge about reorderbuffer implementation
  181. * details this is implemented in reorderbuffer.c not heapam_visibility.c
  182. */
  183. struct HTAB;
  184. extern bool ResolveCminCmaxDuringDecoding(struct HTAB *tuplecid_data,
  185. Snapshot snapshot,
  186. HeapTuple htup,
  187. Buffer buffer,
  188. CommandId *cmin, CommandId *cmax);
  189. #endif /* HEAPAM_H */
上海开阖软件有限公司 沪ICP备12045867号-1