summaryrefslogtreecommitdiff
path: root/src/include/access/gist.h
diff options
context:
space:
mode:
authorNeil Conway2005-05-17 00:59:30 +0000
committerNeil Conway2005-05-17 00:59:30 +0000
commit9ce5db8c7b3e7d550331ea29e4ddb069ab58edf0 (patch)
tree4fd5872d1a5e430fae97da13acd308d7783bde3b /src/include/access/gist.h
parent7846617135900966539372a8ac3fca25779f3e86 (diff)
GiST improvements:
- make sure we always invoke user-supplied GiST methods in a short-lived memory context. This means the backend isn't exposed to any memory leaks that be in those methods (in fact, it is probably a net loss for most GiST methods to bother manually freeing memory now). This also means we can do away with a lot of ugly manual memory management in the GiST code itself. - keep the current page of a GiST index scan pinned, rather than doing a ReadBuffer() for each tuple produced by the scan. Since ReadBuffer() is expensive, this is a perf. win - implement dead tuple killing for GiST indexes (which is easy to do, now that we keep a pin on the current scan page). Now all the builtin indexes implement dead tuple killing. - cleanup a lot of ugly code in GiST
Diffstat (limited to 'src/include/access/gist.h')
-rw-r--r--src/include/access/gist.h33
1 files changed, 22 insertions, 11 deletions
diff --git a/src/include/access/gist.h b/src/include/access/gist.h
index 0bd485b6df..347079beee 100644
--- a/src/include/access/gist.h
+++ b/src/include/access/gist.h
@@ -54,13 +54,21 @@ typedef GISTPageOpaqueData *GISTPageOpaque;
#define GIST_LEAF(entry) (((GISTPageOpaque) PageGetSpecialPointer((entry)->page))->flags & F_LEAF)
/*
- * When we descend a tree, we keep a stack of parent pointers.
+ * When we descend a tree, we keep a stack of parent pointers. This
+ * allows us to follow a chain of internal node points until we reach
+ * a leaf node, and then back up the stack to re-examine the internal
+ * nodes.
+ *
+ * 'parent' is the previous stack entry -- i.e. the node we arrived
+ * from. 'block' is the node's block number. 'offset' is the offset in
+ * the node's page that we stopped at (i.e. we followed the child
+ * pointer located at the specified offset).
*/
typedef struct GISTSTACK
{
- struct GISTSTACK *gs_parent;
- OffsetNumber gs_child;
- BlockNumber gs_blk;
+ struct GISTSTACK *parent;
+ OffsetNumber offset;
+ BlockNumber block;
} GISTSTACK;
typedef struct GISTSTATE
@@ -84,10 +92,13 @@ typedef struct GISTSTATE
*/
typedef struct GISTScanOpaqueData
{
- struct GISTSTACK *s_stack;
- struct GISTSTACK *s_markstk;
- uint16 s_flags;
- struct GISTSTATE *giststate;
+ GISTSTACK *stack;
+ GISTSTACK *markstk;
+ uint16 flags;
+ GISTSTATE *giststate;
+ MemoryContext tempCxt;
+ Buffer curbuf;
+ Buffer markbuf;
} GISTScanOpaqueData;
typedef GISTScanOpaqueData *GISTScanOpaque;
@@ -101,8 +112,8 @@ typedef GISTScanOpaqueData *GISTScanOpaque;
#define GS_CURBEFORE ((uint16) (1 << 0))
#define GS_MRKBEFORE ((uint16) (1 << 1))
-/* root page of a gist */
-#define GISTP_ROOT 0
+/* root page of a gist index */
+#define GIST_ROOT_BLKNO 0
/*
* When we update a relation on which we're doing a scan, we need to
@@ -183,7 +194,6 @@ extern Datum gistbuild(PG_FUNCTION_ARGS);
extern Datum gistinsert(PG_FUNCTION_ARGS);
extern Datum gistbulkdelete(PG_FUNCTION_ARGS);
extern void _gistdump(Relation r);
-extern void gistfreestack(GISTSTACK *s);
extern void initGISTstate(GISTSTATE *giststate, Relation index);
extern void freeGISTstate(GISTSTATE *giststate);
extern void gistdentryinit(GISTSTATE *giststate, int nkey, GISTENTRY *e,
@@ -193,6 +203,7 @@ extern void gistdentryinit(GISTSTATE *giststate, int nkey, GISTENTRY *e,
extern void gist_redo(XLogRecPtr lsn, XLogRecord *record);
extern void gist_undo(XLogRecPtr lsn, XLogRecord *record);
extern void gist_desc(char *buf, uint8 xl_info, char *rec);
+extern MemoryContext createTempGistContext(void);
/* gistget.c */
extern Datum gistgettuple(PG_FUNCTION_ARGS);