1 /*-------------------------------------------------------------------------
4 * POSTGRES heap access method definitions.
7 * Copyright (c) 1994, Regents of the University of California
9 * $Id: heapam.h,v 1.4 1996/11/03 08:17:18 scrappy Exp $
11 *-------------------------------------------------------------------------
16 #include "access/relscan.h"
17 #include "storage/buf.h"
19 /* ----------------------------------------------------------------
20 * heap access method statistics
21 * ----------------------------------------------------------------
24 typedef struct HeapAccessStatisticsData {
25 time_t init_global_timestamp; /* time global statistics started */
26 time_t local_reset_timestamp; /* last time local reset was done */
27 time_t last_request_timestamp; /* last time stats were requested */
42 int global_BufferGetRelation;
43 int global_RelationIdGetRelation;
44 int global_RelationIdGetRelation_Buf;
45 int global_RelationNameGetRelation;
46 int global_getreldesc;
47 int global_heapgettup;
48 int global_RelationPutHeapTuple;
49 int global_RelationPutLongHeapTuple;
64 int local_BufferGetRelation;
65 int local_RelationIdGetRelation;
66 int local_RelationIdGetRelation_Buf;
67 int local_RelationNameGetRelation;
70 int local_RelationPutHeapTuple;
71 int local_RelationPutLongHeapTuple;
72 } HeapAccessStatisticsData;
74 typedef HeapAccessStatisticsData *HeapAccessStatistics;
76 #define IncrHeapAccessStat(x) \
77 (heap_access_stats == NULL ? 0 : (heap_access_stats->x)++)
79 extern HeapAccessStatistics heap_access_stats; /* in stats.c */
82 * function prototypes for heap access method
85 /* heap_create, heap_creatr, and heap_destroy are declared in catalog/heap.h */
86 #include "catalog/heap.h"
89 extern void doinsert(Relation relation, HeapTuple tup);
90 extern void SetHeapAccessMethodImmediateInvalidation(bool on);
92 extern Relation heap_open(Oid relationId);
93 extern Relation heap_openr(char *relationName);
94 extern void heap_close(Relation relation);
95 extern HeapScanDesc heap_beginscan(Relation relation, int atend,
96 TimeQual timeQual, unsigned nkeys, ScanKey key);
97 extern void heap_rescan(HeapScanDesc sdesc, bool scanFromEnd, ScanKey key);
98 extern void heap_endscan(HeapScanDesc sdesc);
99 extern HeapTuple heap_getnext(HeapScanDesc scandesc, int backw, Buffer *b);
100 extern HeapTuple heap_fetch(Relation relation, TimeQual timeQual,
101 ItemPointer tid, Buffer *b);
102 extern Oid heap_insert(Relation relation, HeapTuple tup);
103 extern void heap_delete(Relation relation, ItemPointer tid);
104 extern int heap_replace(Relation relation, ItemPointer otid,
106 extern void heap_markpos(HeapScanDesc sdesc);
107 extern void heap_restrpos(HeapScanDesc sdesc);
109 /* in common/heaptuple.c */
110 extern Size ComputeDataSize(TupleDesc tupleDesc, Datum value[], char nulls[]);
111 extern void DataFill(char *data, TupleDesc tupleDesc,
112 Datum value[], char nulls[], char *infomask,
114 extern int heap_attisnull(HeapTuple tup, int attnum);
115 extern int heap_sysattrlen(AttrNumber attno);
116 extern bool heap_sysattrbyval(AttrNumber attno);
117 extern char *heap_getsysattr(HeapTuple tup, Buffer b, int attnum);
118 extern char *fastgetattr(HeapTuple tup, int attnum,
119 TupleDesc att, bool *isnull);
120 extern char *heap_getattr(HeapTuple tup, Buffer b, int attnum,
121 TupleDesc att, bool *isnull);
122 extern HeapTuple heap_copytuple(HeapTuple tuple);
123 extern void heap_deformtuple(HeapTuple tuple, TupleDesc tdesc,
124 Datum values[], char nulls[]);
125 extern HeapTuple heap_formtuple(TupleDesc tupleDescriptor,
126 Datum value[], char nulls[]);
127 extern HeapTuple heap_modifytuple(HeapTuple tuple, Buffer buffer,
128 Relation relation, Datum replValue[], char replNull[], char repl[]);
129 HeapTuple heap_addheader(uint32 natts, int structlen, char *structure);
131 /* in common/heap/stats.c */
132 extern void InitHeapAccessStatistics(void);
133 extern void ResetHeapAccessStatistics(void);
134 extern HeapAccessStatistics GetHeapAccessStatistics(void);
135 extern void PrintHeapAccessStatistics(HeapAccessStatistics stats);
136 extern void PrintAndFreeHeapAccessStatistics(HeapAccessStatistics stats);
137 extern void initam(void);
139 #endif /* HEAPAM_H */