Fix a few errors in comments. Patch by Fujii Masao, plus the one in
[PostgreSQL.git] / src / include / access / heapam.h
blobee17e4f80add952ae0b256b1b39a80b2c4cffa8d
1 /*-------------------------------------------------------------------------
3 * heapam.h
4 * POSTGRES heap access method definitions.
7 * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
10 * $PostgreSQL$
12 *-------------------------------------------------------------------------
14 #ifndef HEAPAM_H
15 #define HEAPAM_H
17 #include "access/htup.h"
18 #include "access/sdir.h"
19 #include "access/skey.h"
20 #include "access/xlog.h"
21 #include "nodes/primnodes.h"
22 #include "storage/bufpage.h"
23 #include "storage/lock.h"
24 #include "utils/relcache.h"
25 #include "utils/snapshot.h"
28 /* "options" flag bits for heap_insert */
29 #define HEAP_INSERT_SKIP_WAL 0x0001
30 #define HEAP_INSERT_SKIP_FSM 0x0002
32 typedef struct BulkInsertStateData *BulkInsertState;
34 typedef enum
36 LockTupleShared,
37 LockTupleExclusive
38 } LockTupleMode;
41 /* ----------------
42 * function prototypes for heap access method
44 * heap_create, heap_create_with_catalog, and heap_drop_with_catalog
45 * are declared in catalog/heap.h
46 * ----------------
49 /* in heap/heapam.c */
50 extern Relation relation_open(Oid relationId, LOCKMODE lockmode);
51 extern Relation try_relation_open(Oid relationId, LOCKMODE lockmode);
52 extern Relation relation_openrv(const RangeVar *relation, LOCKMODE lockmode);
53 extern Relation try_relation_openrv(const RangeVar *relation, LOCKMODE lockmode);
54 extern void relation_close(Relation relation, LOCKMODE lockmode);
56 extern Relation heap_open(Oid relationId, LOCKMODE lockmode);
57 extern Relation heap_openrv(const RangeVar *relation, LOCKMODE lockmode);
58 extern Relation try_heap_openrv(const RangeVar *relation, LOCKMODE lockmode);
60 #define heap_close(r,l) relation_close(r,l)
62 /* struct definition appears in relscan.h */
63 typedef struct HeapScanDescData *HeapScanDesc;
66 * HeapScanIsValid
67 * True iff the heap scan is valid.
69 #define HeapScanIsValid(scan) PointerIsValid(scan)
71 extern HeapScanDesc heap_beginscan(Relation relation, Snapshot snapshot,
72 int nkeys, ScanKey key);
73 extern HeapScanDesc heap_beginscan_strat(Relation relation, Snapshot snapshot,
74 int nkeys, ScanKey key,
75 bool allow_strat, bool allow_sync);
76 extern HeapScanDesc heap_beginscan_bm(Relation relation, Snapshot snapshot,
77 int nkeys, ScanKey key);
78 extern void heap_rescan(HeapScanDesc scan, ScanKey key);
79 extern void heap_endscan(HeapScanDesc scan);
80 extern HeapTuple heap_getnext(HeapScanDesc scan, ScanDirection direction);
82 extern bool heap_fetch(Relation relation, Snapshot snapshot,
83 HeapTuple tuple, Buffer *userbuf, bool keep_buf,
84 Relation stats_relation);
85 extern bool heap_hot_search_buffer(ItemPointer tid, Buffer buffer,
86 Snapshot snapshot, bool *all_dead);
87 extern bool heap_hot_search(ItemPointer tid, Relation relation,
88 Snapshot snapshot, bool *all_dead);
90 extern void heap_get_latest_tid(Relation relation, Snapshot snapshot,
91 ItemPointer tid);
92 extern void setLastTid(const ItemPointer tid);
94 extern BulkInsertState GetBulkInsertState(void);
95 extern void FreeBulkInsertState(BulkInsertState);
97 extern Oid heap_insert(Relation relation, HeapTuple tup, CommandId cid,
98 int options, BulkInsertState bistate);
99 extern HTSU_Result heap_delete(Relation relation, ItemPointer tid,
100 ItemPointer ctid, TransactionId *update_xmax,
101 CommandId cid, Snapshot crosscheck, bool wait);
102 extern HTSU_Result heap_update(Relation relation, ItemPointer otid,
103 HeapTuple newtup,
104 ItemPointer ctid, TransactionId *update_xmax,
105 CommandId cid, Snapshot crosscheck, bool wait);
106 extern HTSU_Result heap_lock_tuple(Relation relation, HeapTuple tuple,
107 Buffer *buffer, ItemPointer ctid,
108 TransactionId *update_xmax, CommandId cid,
109 LockTupleMode mode, bool nowait);
110 extern void heap_inplace_update(Relation relation, HeapTuple tuple);
111 extern bool heap_freeze_tuple(HeapTupleHeader tuple, TransactionId cutoff_xid,
112 Buffer buf);
114 extern Oid simple_heap_insert(Relation relation, HeapTuple tup);
115 extern void simple_heap_delete(Relation relation, ItemPointer tid);
116 extern void simple_heap_update(Relation relation, ItemPointer otid,
117 HeapTuple tup);
119 extern void heap_markpos(HeapScanDesc scan);
120 extern void heap_restrpos(HeapScanDesc scan);
122 extern void heap_sync(Relation relation);
124 extern void heap_redo(XLogRecPtr lsn, XLogRecord *rptr);
125 extern void heap_desc(StringInfo buf, uint8 xl_info, char *rec);
126 extern void heap2_redo(XLogRecPtr lsn, XLogRecord *rptr);
127 extern void heap2_desc(StringInfo buf, uint8 xl_info, char *rec);
129 extern XLogRecPtr log_heap_move(Relation reln, Buffer oldbuf,
130 ItemPointerData from,
131 Buffer newbuf, HeapTuple newtup);
132 extern XLogRecPtr log_heap_clean(Relation reln, Buffer buffer,
133 OffsetNumber *redirected, int nredirected,
134 OffsetNumber *nowdead, int ndead,
135 OffsetNumber *nowunused, int nunused,
136 bool redirect_move);
137 extern XLogRecPtr log_heap_freeze(Relation reln, Buffer buffer,
138 TransactionId cutoff_xid,
139 OffsetNumber *offsets, int offcnt);
140 extern XLogRecPtr log_newpage(RelFileNode *rnode, ForkNumber forkNum,
141 BlockNumber blk, Page page);
143 /* in heap/pruneheap.c */
144 extern void heap_page_prune_opt(Relation relation, Buffer buffer,
145 TransactionId OldestXmin);
146 extern int heap_page_prune(Relation relation, Buffer buffer,
147 TransactionId OldestXmin,
148 bool redirect_move, bool report_stats);
149 extern void heap_page_prune_execute(Buffer buffer,
150 OffsetNumber *redirected, int nredirected,
151 OffsetNumber *nowdead, int ndead,
152 OffsetNumber *nowunused, int nunused,
153 bool redirect_move);
154 extern void heap_get_root_tuples(Page page, OffsetNumber *root_offsets);
156 /* in heap/syncscan.c */
157 extern void ss_report_location(Relation rel, BlockNumber location);
158 extern BlockNumber ss_get_location(Relation rel, BlockNumber relnblocks);
159 extern void SyncScanShmemInit(void);
160 extern Size SyncScanShmemSize(void);
162 #endif /* HEAPAM_H */