OSDN Git Service

And another one
[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.5 1996/11/05 07:22:50 scrappy Exp $
10  *
11  *-------------------------------------------------------------------------
12  */
13 #ifndef HEAPAM_H
14 #define HEAPAM_H
15
16 #include <access/relscan.h>
17
18 /* ----------------------------------------------------------------
19  *              heap access method statistics
20  * ----------------------------------------------------------------
21  */
22
23 typedef struct HeapAccessStatisticsData {
24     time_t  init_global_timestamp;      /* time global statistics started */
25     time_t  local_reset_timestamp;      /* last time local reset was done */
26     time_t  last_request_timestamp;     /* last time stats were requested */
27
28     int global_open;                    
29     int global_openr;
30     int global_close;
31     int global_beginscan;
32     int global_rescan;
33     int global_endscan;
34     int global_getnext;
35     int global_fetch;
36     int global_insert;
37     int global_delete;
38     int global_replace; 
39     int global_markpos; 
40     int global_restrpos;
41     int global_BufferGetRelation;
42     int global_RelationIdGetRelation;
43     int global_RelationIdGetRelation_Buf;
44     int global_RelationNameGetRelation;
45     int global_getreldesc;
46     int global_heapgettup;
47     int global_RelationPutHeapTuple;
48     int global_RelationPutLongHeapTuple;
49
50     int local_open;                     
51     int local_openr;
52     int local_close;
53     int local_beginscan;
54     int local_rescan;
55     int local_endscan;
56     int local_getnext;
57     int local_fetch;
58     int local_insert;
59     int local_delete;
60     int local_replace; 
61     int local_markpos; 
62     int local_restrpos;
63     int local_BufferGetRelation;
64     int local_RelationIdGetRelation;
65     int local_RelationIdGetRelation_Buf;
66     int local_RelationNameGetRelation;
67     int local_getreldesc;
68     int local_heapgettup;
69     int local_RelationPutHeapTuple;
70     int local_RelationPutLongHeapTuple;
71 } HeapAccessStatisticsData;
72
73 typedef HeapAccessStatisticsData *HeapAccessStatistics;
74
75 #define IncrHeapAccessStat(x) \
76     (heap_access_stats == NULL ? 0 : (heap_access_stats->x)++)
77
78 extern HeapAccessStatistics heap_access_stats;  /* in stats.c */
79
80 /* ----------------
81  *      function prototypes for heap access method
82  * ----------------
83  */
84 /* heap_create, heap_creatr, and heap_destroy are declared in catalog/heap.h */
85
86 /* heapam.c */
87 extern void doinsert(Relation relation, HeapTuple tup);
88 extern void SetHeapAccessMethodImmediateInvalidation(bool on);
89
90 extern Relation heap_open(Oid relationId);
91 extern Relation heap_openr(char *relationName);
92 extern void heap_close(Relation relation);
93 extern HeapScanDesc heap_beginscan(Relation relation, int atend,
94                             TimeQual timeQual, unsigned nkeys, ScanKey key);
95 extern void heap_rescan(HeapScanDesc sdesc, bool scanFromEnd, ScanKey key);
96 extern void heap_endscan(HeapScanDesc sdesc);
97 extern HeapTuple heap_getnext(HeapScanDesc scandesc, int backw, Buffer *b);
98 extern HeapTuple heap_fetch(Relation relation, TimeQual timeQual,
99                             ItemPointer tid, Buffer *b);
100 extern Oid heap_insert(Relation relation, HeapTuple tup);
101 extern void heap_delete(Relation relation, ItemPointer tid);
102 extern int heap_replace(Relation relation, ItemPointer otid,
103                         HeapTuple tup);
104 extern void heap_markpos(HeapScanDesc sdesc);
105 extern void heap_restrpos(HeapScanDesc sdesc);
106
107 /* in common/heaptuple.c */
108 extern Size ComputeDataSize(TupleDesc tupleDesc, Datum value[], char nulls[]);
109 extern void DataFill(char *data, TupleDesc tupleDesc,
110                      Datum value[], char nulls[], char *infomask,
111                      bits8 *bit);
112 extern int heap_attisnull(HeapTuple tup, int attnum);
113 extern int heap_sysattrlen(AttrNumber attno);
114 extern bool heap_sysattrbyval(AttrNumber attno);
115 extern char *heap_getsysattr(HeapTuple tup, Buffer b, int attnum);
116 extern char *fastgetattr(HeapTuple tup, int attnum,
117                          TupleDesc att, bool *isnull);
118 extern char *heap_getattr(HeapTuple tup, Buffer b, int attnum,
119                           TupleDesc att, bool *isnull);
120 extern HeapTuple heap_copytuple(HeapTuple tuple);
121 extern void heap_deformtuple(HeapTuple tuple, TupleDesc tdesc,
122                              Datum values[], char nulls[]);
123 extern HeapTuple heap_formtuple(TupleDesc tupleDescriptor, 
124                                 Datum value[], char nulls[]);
125 extern HeapTuple heap_modifytuple(HeapTuple tuple, Buffer buffer,
126         Relation relation, Datum replValue[], char replNull[], char repl[]);
127 HeapTuple heap_addheader(uint32 natts, int structlen, char *structure);
128
129 /* in common/heap/stats.c */
130 extern void InitHeapAccessStatistics(void);
131 extern void ResetHeapAccessStatistics(void);
132 extern HeapAccessStatistics GetHeapAccessStatistics(void);
133 extern void PrintHeapAccessStatistics(HeapAccessStatistics stats);
134 extern void PrintAndFreeHeapAccessStatistics(HeapAccessStatistics stats);
135 extern void initam(void);
136
137 #endif  /* HEAPAM_H */