OSDN Git Service

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