00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef HEAPAM_H
00015 #define HEAPAM_H
00016
00017 #include "access/sdir.h"
00018 #include "access/skey.h"
00019 #include "nodes/primnodes.h"
00020 #include "storage/bufpage.h"
00021 #include "storage/lock.h"
00022 #include "utils/relcache.h"
00023 #include "utils/snapshot.h"
00024
00025
00026
00027 #define HEAP_INSERT_SKIP_WAL 0x0001
00028 #define HEAP_INSERT_SKIP_FSM 0x0002
00029 #define HEAP_INSERT_FROZEN 0x0004
00030
00031 typedef struct BulkInsertStateData *BulkInsertState;
00032
00033
00034
00035
00036 typedef enum LockTupleMode
00037 {
00038
00039 LockTupleKeyShare,
00040
00041 LockTupleShare,
00042
00043 LockTupleNoKeyExclusive,
00044
00045 LockTupleExclusive
00046 } LockTupleMode;
00047
00048 #define MaxLockTupleMode LockTupleExclusive
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066 typedef struct HeapUpdateFailureData
00067 {
00068 ItemPointerData ctid;
00069 TransactionId xmax;
00070 CommandId cmax;
00071 } HeapUpdateFailureData;
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083 extern Relation relation_open(Oid relationId, LOCKMODE lockmode);
00084 extern Relation try_relation_open(Oid relationId, LOCKMODE lockmode);
00085 extern Relation relation_openrv(const RangeVar *relation, LOCKMODE lockmode);
00086 extern Relation relation_openrv_extended(const RangeVar *relation,
00087 LOCKMODE lockmode, bool missing_ok);
00088 extern void relation_close(Relation relation, LOCKMODE lockmode);
00089
00090 extern Relation heap_open(Oid relationId, LOCKMODE lockmode);
00091 extern Relation heap_openrv(const RangeVar *relation, LOCKMODE lockmode);
00092 extern Relation heap_openrv_extended(const RangeVar *relation,
00093 LOCKMODE lockmode, bool missing_ok);
00094
00095 #define heap_close(r,l) relation_close(r,l)
00096
00097
00098 typedef struct HeapScanDescData *HeapScanDesc;
00099
00100
00101
00102
00103
00104 #define HeapScanIsValid(scan) PointerIsValid(scan)
00105
00106 extern HeapScanDesc heap_beginscan(Relation relation, Snapshot snapshot,
00107 int nkeys, ScanKey key);
00108 extern HeapScanDesc heap_beginscan_strat(Relation relation, Snapshot snapshot,
00109 int nkeys, ScanKey key,
00110 bool allow_strat, bool allow_sync);
00111 extern HeapScanDesc heap_beginscan_bm(Relation relation, Snapshot snapshot,
00112 int nkeys, ScanKey key);
00113 extern void heap_rescan(HeapScanDesc scan, ScanKey key);
00114 extern void heap_endscan(HeapScanDesc scan);
00115 extern HeapTuple heap_getnext(HeapScanDesc scan, ScanDirection direction);
00116
00117 extern bool heap_fetch(Relation relation, Snapshot snapshot,
00118 HeapTuple tuple, Buffer *userbuf, bool keep_buf,
00119 Relation stats_relation);
00120 extern bool heap_hot_search_buffer(ItemPointer tid, Relation relation,
00121 Buffer buffer, Snapshot snapshot, HeapTuple heapTuple,
00122 bool *all_dead, bool first_call);
00123 extern bool heap_hot_search(ItemPointer tid, Relation relation,
00124 Snapshot snapshot, bool *all_dead);
00125
00126 extern void heap_get_latest_tid(Relation relation, Snapshot snapshot,
00127 ItemPointer tid);
00128 extern void setLastTid(const ItemPointer tid);
00129
00130 extern BulkInsertState GetBulkInsertState(void);
00131 extern void FreeBulkInsertState(BulkInsertState);
00132
00133 extern Oid heap_insert(Relation relation, HeapTuple tup, CommandId cid,
00134 int options, BulkInsertState bistate);
00135 extern void heap_multi_insert(Relation relation, HeapTuple *tuples, int ntuples,
00136 CommandId cid, int options, BulkInsertState bistate);
00137 extern HTSU_Result heap_delete(Relation relation, ItemPointer tid,
00138 CommandId cid, Snapshot crosscheck, bool wait,
00139 HeapUpdateFailureData *hufd);
00140 extern HTSU_Result heap_update(Relation relation, ItemPointer otid,
00141 HeapTuple newtup,
00142 CommandId cid, Snapshot crosscheck, bool wait,
00143 HeapUpdateFailureData *hufd, LockTupleMode *lockmode);
00144 extern HTSU_Result heap_lock_tuple(Relation relation, HeapTuple tuple,
00145 CommandId cid, LockTupleMode mode, bool nowait,
00146 bool follow_update,
00147 Buffer *buffer, HeapUpdateFailureData *hufd);
00148 extern void heap_inplace_update(Relation relation, HeapTuple tuple);
00149 extern bool heap_freeze_tuple(HeapTupleHeader tuple, TransactionId cutoff_xid,
00150 TransactionId cutoff_multi);
00151 extern bool heap_tuple_needs_freeze(HeapTupleHeader tuple, TransactionId cutoff_xid,
00152 MultiXactId cutoff_multi, Buffer buf);
00153
00154 extern Oid simple_heap_insert(Relation relation, HeapTuple tup);
00155 extern void simple_heap_delete(Relation relation, ItemPointer tid);
00156 extern void simple_heap_update(Relation relation, ItemPointer otid,
00157 HeapTuple tup);
00158
00159 extern void heap_markpos(HeapScanDesc scan);
00160 extern void heap_restrpos(HeapScanDesc scan);
00161
00162 extern void heap_sync(Relation relation);
00163
00164
00165 extern void heap_page_prune_opt(Relation relation, Buffer buffer,
00166 TransactionId OldestXmin);
00167 extern int heap_page_prune(Relation relation, Buffer buffer,
00168 TransactionId OldestXmin,
00169 bool report_stats, TransactionId *latestRemovedXid);
00170 extern void heap_page_prune_execute(Buffer buffer,
00171 OffsetNumber *redirected, int nredirected,
00172 OffsetNumber *nowdead, int ndead,
00173 OffsetNumber *nowunused, int nunused);
00174 extern void heap_get_root_tuples(Page page, OffsetNumber *root_offsets);
00175
00176
00177 extern void ss_report_location(Relation rel, BlockNumber location);
00178 extern BlockNumber ss_get_location(Relation rel, BlockNumber relnblocks);
00179 extern void SyncScanShmemInit(void);
00180 extern Size SyncScanShmemSize(void);
00181
00182 #endif