OSDN Git Service

Another PGINDENT run that changes variable indenting and case label indenting. Also...
[pg-rex/syncrep.git] / src / include / access / heapam.h
1 /*-------------------------------------------------------------------------
2  *
3  * heapam.h--
4  *        POSTGRES heap access method definitions.
5  *
6  *
7  * Copyright (c) 1994, Regents of the University of California
8  *
9  * $Id: heapam.h,v 1.13 1997/09/08 02:34:10 momjian Exp $
10  *
11  *-------------------------------------------------------------------------
12  */
13 #ifndef HEAPAM_H
14 #define HEAPAM_H
15
16 #include <access/htup.h>
17 #include <access/relscan.h>
18 #include <storage/block.h>
19 #include <utils/rel.h>
20
21 /* ----------------------------------------------------------------
22  *                              heap access method statistics
23  * ----------------------------------------------------------------
24  */
25
26 typedef struct HeapAccessStatisticsData
27 {
28         time_t          init_global_timestamp;  /* time global statistics started */
29         time_t          local_reset_timestamp;  /* last time local reset was done */
30         time_t          last_request_timestamp; /* last time stats were requested */
31
32         int                     global_open;
33         int                     global_openr;
34         int                     global_close;
35         int                     global_beginscan;
36         int                     global_rescan;
37         int                     global_endscan;
38         int                     global_getnext;
39         int                     global_fetch;
40         int                     global_insert;
41         int                     global_delete;
42         int                     global_replace;
43         int                     global_markpos;
44         int                     global_restrpos;
45         int                     global_BufferGetRelation;
46         int                     global_RelationIdGetRelation;
47         int                     global_RelationIdGetRelation_Buf;
48         int                     global_RelationNameGetRelation;
49         int                     global_getreldesc;
50         int                     global_heapgettup;
51         int                     global_RelationPutHeapTuple;
52         int                     global_RelationPutLongHeapTuple;
53
54         int                     local_open;
55         int                     local_openr;
56         int                     local_close;
57         int                     local_beginscan;
58         int                     local_rescan;
59         int                     local_endscan;
60         int                     local_getnext;
61         int                     local_fetch;
62         int                     local_insert;
63         int                     local_delete;
64         int                     local_replace;
65         int                     local_markpos;
66         int                     local_restrpos;
67         int                     local_BufferGetRelation;
68         int                     local_RelationIdGetRelation;
69         int                     local_RelationIdGetRelation_Buf;
70         int                     local_RelationNameGetRelation;
71         int                     local_getreldesc;
72         int                     local_heapgettup;
73         int                     local_RelationPutHeapTuple;
74         int                     local_RelationPutLongHeapTuple;
75 }                       HeapAccessStatisticsData;
76
77 typedef HeapAccessStatisticsData *HeapAccessStatistics;
78
79 #define IncrHeapAccessStat(x) \
80         (heap_access_stats == NULL ? 0 : (heap_access_stats->x)++)
81
82 /* ----------------
83  *              heap_getattr
84  *
85  *              Find a particular field in a row represented as a heap tuple.
86  *              We return a pointer into that heap tuple, which points to the
87  *              first byte of the value of the field in question.
88  *
89  *              If the field in question has a NULL value, we return a null
90  *              pointer and return <*isnull> == true.  Otherwise, we return
91  *              <*isnull> == false.
92  *
93  *              <tup> is the pointer to the heap tuple.  <attnum> is the attribute
94  *              number of the column (field) caller wants.      <tupleDesc> is a
95  *              pointer to the structure describing the row and all its fields.
96  * ---------------- */
97 #define heap_getattr(tup, b, attnum, tupleDesc, isnull) \
98         (AssertMacro((tup) != NULL) ? \
99                 ((attnum) > (int) (tup)->t_natts) ? \
100                         (((isnull) ? (*(isnull) = true) : (char)NULL), (char *)NULL) : \
101                 ((attnum) > 0) ? \
102                         fastgetattr((tup), (attnum), (tupleDesc), (isnull)) : \
103                 (((isnull) ? (*(isnull) = false) : (char)NULL), heap_getsysattr((tup), (b), (attnum))) : \
104         (char *)NULL)
105
106 extern HeapAccessStatistics heap_access_stats;  /* in stats.c */
107
108 /* ----------------
109  *              function prototypes for heap access method
110  * ----------------
111  */
112 /* heap_create, heap_creatr, and heap_destroy are declared in catalog/heap.h */
113
114 /* heapam.c */
115 extern void doinsert(Relation relation, HeapTuple tup);
116
117 extern Relation heap_open(Oid relationId);
118 extern Relation heap_openr(char *relationName);
119 extern void heap_close(Relation relation);
120 extern          HeapScanDesc
121 heap_beginscan(Relation relation, int atend,
122                            TimeQual timeQual, unsigned nkeys, ScanKey key);
123 extern void heap_rescan(HeapScanDesc sdesc, bool scanFromEnd, ScanKey key);
124 extern void heap_endscan(HeapScanDesc sdesc);
125 extern HeapTuple heap_getnext(HeapScanDesc scandesc, int backw, Buffer * b);
126 extern          HeapTuple
127 heap_fetch(Relation relation, TimeQual timeQual,
128                    ItemPointer tid, Buffer * b);
129 extern Oid      heap_insert(Relation relation, HeapTuple tup);
130 extern int      heap_delete(Relation relation, ItemPointer tid);
131 extern int
132 heap_replace(Relation relation, ItemPointer otid,
133                          HeapTuple tup);
134 extern void heap_markpos(HeapScanDesc sdesc);
135 extern void heap_restrpos(HeapScanDesc sdesc);
136
137 /* in common/heaptuple.c */
138 extern Size ComputeDataSize(TupleDesc tupleDesc, Datum value[], char nulls[]);
139 extern void
140 DataFill(char *data, TupleDesc tupleDesc,
141                  Datum value[], char nulls[], char *infomask,
142                  bits8 * bit);
143 extern int      heap_attisnull(HeapTuple tup, int attnum);
144 extern int      heap_sysattrlen(AttrNumber attno);
145 extern bool heap_sysattrbyval(AttrNumber attno);
146 extern char *heap_getsysattr(HeapTuple tup, Buffer b, int attnum);
147 extern char *
148 fastgetattr(HeapTuple tup, int attnum,
149                         TupleDesc att, bool * isnull);
150 extern HeapTuple heap_copytuple(HeapTuple tuple);
151 extern          HeapTuple
152 heap_formtuple(TupleDesc tupleDescriptor,
153                            Datum value[], char nulls[]);
154 extern          HeapTuple
155 heap_modifytuple(HeapTuple tuple, Buffer buffer,
156          Relation relation, Datum replValue[], char replNull[], char repl[]);
157 HeapTuple       heap_addheader(uint32 natts, int structlen, char *structure);
158
159 /* in common/heap/stats.c */
160 extern void PrintHeapAccessStatistics(HeapAccessStatistics stats);
161 extern void initam(void);
162
163 /* hio.c */
164 extern void
165 RelationPutHeapTuple(Relation relation, BlockNumber blockIndex,
166                                          HeapTuple tuple);
167 extern void RelationPutHeapTupleAtEnd(Relation relation, HeapTuple tuple);
168
169 #endif                                                  /* HEAPAM_H */