11/*-------------------------------------------------------------------------
22 *
33 * gist.h
4- * common declarations for the GiST access method code.
4+ * The public API for GiST indexes. This API is exposed to
5+ * individuals implementing GiST indexes, so backward-incompatible
6+ * changes should be made with care.
57 *
68 *
79 * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
810 * Portions Copyright (c) 1994, Regents of the University of California
911 *
10- * $PostgreSQL: pgsql/src/include/access/gist.h,v 1.45 2005/05/17 00:59:30 neilc Exp $
12+ * $PostgreSQL: pgsql/src/include/access/gist.h,v 1.46 2005/05/17 03:34:18 neilc Exp $
1113 *
1214 *-------------------------------------------------------------------------
1315 */
1416#ifndef GIST_H
1517#define GIST_H
1618
17- #include "access/itup.h"
18- #include "access/relscan.h"
19- #include "access/sdir.h"
20- #include "access/xlog.h"
21-
22- /*
23- * You can have as many strategies as you please in GiSTs,
24- * as long as your consistent method can handle them.
25- * The system doesn't really care what they are.
26- */
27- #define GISTNStrategies 100
19+ #include "storage/bufpage.h"
20+ #include "storage/off.h"
21+ #include "utils/rel.h"
2822
2923/*
3024 * amproc indexes for GiST indexes.
3832#define GIST_EQUAL_PROC 7
3933#define GISTNProcs 7
4034
41-
4235/*
4336 * Page opaque data in a GiST index page.
4437 */
@@ -51,81 +44,6 @@ typedef struct GISTPageOpaqueData
5144
5245typedef GISTPageOpaqueData * GISTPageOpaque ;
5346
54- #define GIST_LEAF (entry ) (((GISTPageOpaque) PageGetSpecialPointer((entry)->page))->flags & F_LEAF)
55-
56- /*
57- * When we descend a tree, we keep a stack of parent pointers. This
58- * allows us to follow a chain of internal node points until we reach
59- * a leaf node, and then back up the stack to re-examine the internal
60- * nodes.
61- *
62- * 'parent' is the previous stack entry -- i.e. the node we arrived
63- * from. 'block' is the node's block number. 'offset' is the offset in
64- * the node's page that we stopped at (i.e. we followed the child
65- * pointer located at the specified offset).
66- */
67- typedef struct GISTSTACK
68- {
69- struct GISTSTACK * parent ;
70- OffsetNumber offset ;
71- BlockNumber block ;
72- } GISTSTACK ;
73-
74- typedef struct GISTSTATE
75- {
76- FmgrInfo consistentFn [INDEX_MAX_KEYS ];
77- FmgrInfo unionFn [INDEX_MAX_KEYS ];
78- FmgrInfo compressFn [INDEX_MAX_KEYS ];
79- FmgrInfo decompressFn [INDEX_MAX_KEYS ];
80- FmgrInfo penaltyFn [INDEX_MAX_KEYS ];
81- FmgrInfo picksplitFn [INDEX_MAX_KEYS ];
82- FmgrInfo equalFn [INDEX_MAX_KEYS ];
83-
84- TupleDesc tupdesc ;
85- } GISTSTATE ;
86-
87- #define isAttByVal ( gs , anum ) (gs)->tupdesc->attrs[anum]->attbyval
88-
89- /*
90- * When we're doing a scan, we need to keep track of the parent stack
91- * for the marked and current items.
92- */
93- typedef struct GISTScanOpaqueData
94- {
95- GISTSTACK * stack ;
96- GISTSTACK * markstk ;
97- uint16 flags ;
98- GISTSTATE * giststate ;
99- MemoryContext tempCxt ;
100- Buffer curbuf ;
101- Buffer markbuf ;
102- } GISTScanOpaqueData ;
103-
104- typedef GISTScanOpaqueData * GISTScanOpaque ;
105-
106- /*
107- * When we're doing a scan and updating a tree at the same time, the
108- * updates may affect the scan. We use the flags entry of the scan's
109- * opaque space to record our actual position in response to updates
110- * that we can't handle simply by adjusting pointers.
111- */
112- #define GS_CURBEFORE ((uint16) (1 << 0))
113- #define GS_MRKBEFORE ((uint16) (1 << 1))
114-
115- /* root page of a gist index */
116- #define GIST_ROOT_BLKNO 0
117-
118- /*
119- * When we update a relation on which we're doing a scan, we need to
120- * check the scan and fix it if the update affected any of the pages it
121- * touches. Otherwise, we can miss records that we should see. The only
122- * times we need to do this are for deletions and splits. See the code in
123- * gistscan.c for how the scan is fixed. These two constants tell us what sort
124- * of operation changed the index.
125- */
126- #define GISTOP_DEL 0
127- #define GISTOP_SPLIT 1
128-
12947/*
13048 * This is the Split Vector to be returned by the PickSplit method.
13149 */
@@ -153,10 +71,10 @@ typedef struct GIST_SPLITVEC
15371} GIST_SPLITVEC ;
15472
15573/*
156- * An entry on a GiST node. Contains the key, as well as
157- * its own location (rel,page,offset) which can supply the matching
158- * pointer. The size of the key is in bytes, and leafkey is a flag to
159- * tell us if the entry is in a leaf node.
74+ * An entry on a GiST node. Contains the key, as well as its own
75+ * location (rel,page,offset) which can supply the matching pointer.
76+ * The size of the key is in bytes, and leafkey is a flag to tell us
77+ * if the entry is in a leaf node.
16078 */
16179typedef struct GISTENTRY
16280{
@@ -168,19 +86,19 @@ typedef struct GISTENTRY
16886 bool leafkey ;
16987} GISTENTRY ;
17088
89+ #define GIST_LEAF (entry ) (((GISTPageOpaque) PageGetSpecialPointer((entry)->page))->flags & F_LEAF)
17190
17291/*
173- * Vector of GISTENTRY struct's, user-defined
174- * methods union andpick split takes it as one of args
92+ * Vector of GISTENTRY structs; user-defined methods union and pick
93+ * split takes it as one of their arguments
17594 */
176-
17795typedef struct
17896{
17997 int32 n ; /* number of elements */
18098 GISTENTRY vector [1 ];
18199} GistEntryVector ;
182100
183- #define GEVHDRSZ ( offsetof(GistEntryVector, vector[0]) )
101+ #define GEVHDRSZ (offsetof(GistEntryVector, vector[0]))
184102
185103/*
186104 * macro to initialize a GISTENTRY
@@ -189,24 +107,4 @@ typedef struct
189107 do { (e).key = (k); (e).rel = (r); (e).page = (pg); \
190108 (e).offset = (o); (e).bytes = (b); (e).leafkey = (l); } while (0)
191109
192- /* gist.c */
193- extern Datum gistbuild (PG_FUNCTION_ARGS );
194- extern Datum gistinsert (PG_FUNCTION_ARGS );
195- extern Datum gistbulkdelete (PG_FUNCTION_ARGS );
196- extern void _gistdump (Relation r );
197- extern void initGISTstate (GISTSTATE * giststate , Relation index );
198- extern void freeGISTstate (GISTSTATE * giststate );
199- extern void gistdentryinit (GISTSTATE * giststate , int nkey , GISTENTRY * e ,
200- Datum k , Relation r , Page pg , OffsetNumber o ,
201- int b , bool l , bool isNull );
202-
203- extern void gist_redo (XLogRecPtr lsn , XLogRecord * record );
204- extern void gist_undo (XLogRecPtr lsn , XLogRecord * record );
205- extern void gist_desc (char * buf , uint8 xl_info , char * rec );
206- extern MemoryContext createTempGistContext (void );
207-
208- /* gistget.c */
209- extern Datum gistgettuple (PG_FUNCTION_ARGS );
210- extern Datum gistgetmulti (PG_FUNCTION_ARGS );
211-
212110#endif /* GIST_H */
0 commit comments