1 /*-------------------------------------------------------------------------
4 * POSTGRES heap access method definitions.
7 * Copyright (c) 1994, Regents of the University of California
9 * $Id: heapam.h,v 1.2 1996/09/23 08:36:39 scrappy Exp $
11 *-------------------------------------------------------------------------
16 #include <sys/types.h>
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"
29 /* ----------------------------------------------------------------
30 * heap access method statistics
31 * ----------------------------------------------------------------
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 */
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;
74 int local_BufferGetRelation;
75 int local_RelationIdGetRelation;
76 int local_RelationIdGetRelation_Buf;
77 int local_RelationNameGetRelation;
80 int local_RelationPutHeapTuple;
81 int local_RelationPutLongHeapTuple;
82 } HeapAccessStatisticsData;
84 typedef HeapAccessStatisticsData *HeapAccessStatistics;
86 #define IncrHeapAccessStat(x) \
87 (heap_access_stats == NULL ? 0 : (heap_access_stats->x)++)
89 extern HeapAccessStatistics heap_access_stats; /* in stats.c */
92 * function prototypes for heap access method
95 /* heap_create, heap_creatr, and heap_destroy are declared in catalog/heap.h */
96 #include "catalog/heap.h"
99 extern void doinsert(Relation relation, HeapTuple tup);
100 extern void SetHeapAccessMethodImmediateInvalidation(bool on);
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,
116 extern void heap_markpos(HeapScanDesc sdesc);
117 extern void heap_restrpos(HeapScanDesc sdesc);
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,
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);
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);
149 #endif /* HEAPAM_H */