diff options
author | Neil Conway <neilc@samurai.com> | 2005-05-17 03:34:18 +0000 |
---|---|---|
committer | Neil Conway <neilc@samurai.com> | 2005-05-17 03:34:18 +0000 |
commit | c891e05f2600206122e200e1cb3d4c360357f980 (patch) | |
tree | 1eaa26147296683a8113afc6fb5e7fefc898b3d4 /src/include/access/gist_private.h | |
parent | eda6dd32d15fe85bfddf6caf32d1a861c4fa5957 (diff) | |
download | postgresql-c891e05f2600206122e200e1cb3d4c360357f980.tar.gz postgresql-c891e05f2600206122e200e1cb3d4c360357f980.zip |
Cleanup GiST header files. Since GiST extensions are often written as
external projects, we should be careful about what parts of the GiST
API are considered implementation details, and which are part of the
public API. Therefore, I've moved internal-only declarations into
gist_private.h -- future backward-incompatible changes to gist.h should
be made with care, to avoid needlessly breaking external GiST extensions.
Also did some related header cleanup: remove some unnecessary #includes
from gist.h, and remove some unused definitions: isAttByVal(), _gistdump(),
and GISTNStrategies.
Diffstat (limited to 'src/include/access/gist_private.h')
-rw-r--r-- | src/include/access/gist_private.h | 110 |
1 files changed, 110 insertions, 0 deletions
diff --git a/src/include/access/gist_private.h b/src/include/access/gist_private.h new file mode 100644 index 00000000000..a34e29d0e05 --- /dev/null +++ b/src/include/access/gist_private.h @@ -0,0 +1,110 @@ +/*------------------------------------------------------------------------- + * + * gist_private.h + * private declarations for GiST -- declarations related to the + * internal implementation of GiST, not the public API + * + * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group + * Portions Copyright (c) 1994, Regents of the University of California + * + * $PostgreSQL: pgsql/src/include/access/gist_private.h,v 1.1 2005/05/17 03:34:18 neilc Exp $ + * + *------------------------------------------------------------------------- + */ +#ifndef GIST_PRIVATE_H +#define GIST_PRIVATE_H + +#include "access/gist.h" +#include "access/xlog.h" +#include "fmgr.h" + +/* + * 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 *parent; + OffsetNumber offset; + BlockNumber block; +} GISTSTACK; + +typedef struct GISTSTATE +{ + FmgrInfo consistentFn[INDEX_MAX_KEYS]; + FmgrInfo unionFn[INDEX_MAX_KEYS]; + FmgrInfo compressFn[INDEX_MAX_KEYS]; + FmgrInfo decompressFn[INDEX_MAX_KEYS]; + FmgrInfo penaltyFn[INDEX_MAX_KEYS]; + FmgrInfo picksplitFn[INDEX_MAX_KEYS]; + FmgrInfo equalFn[INDEX_MAX_KEYS]; + + TupleDesc tupdesc; +} GISTSTATE; + +/* + * When we're doing a scan, we need to keep track of the parent stack + * for the marked and current items. + */ +typedef struct GISTScanOpaqueData +{ + GISTSTACK *stack; + GISTSTACK *markstk; + uint16 flags; + GISTSTATE *giststate; + MemoryContext tempCxt; + Buffer curbuf; + Buffer markbuf; +} GISTScanOpaqueData; + +typedef GISTScanOpaqueData *GISTScanOpaque; + +/* + * When we're doing a scan and updating a tree at the same time, the + * updates may affect the scan. We use the flags entry of the scan's + * opaque space to record our actual position in response to updates + * that we can't handle simply by adjusting pointers. + */ +#define GS_CURBEFORE ((uint16) (1 << 0)) +#define GS_MRKBEFORE ((uint16) (1 << 1)) + +/* 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 + * check the scan and fix it if the update affected any of the pages + * it touches. Otherwise, we can miss records that we should see. + * The only times we need to do this are for deletions and splits. See + * the code in gistscan.c for how the scan is fixed. These two + * constants tell us what sort of operation changed the index. + */ +#define GISTOP_DEL 0 +#define GISTOP_SPLIT 1 + +/* gist.c */ +extern Datum gistbuild(PG_FUNCTION_ARGS); +extern Datum gistinsert(PG_FUNCTION_ARGS); +extern Datum gistbulkdelete(PG_FUNCTION_ARGS); +extern MemoryContext createTempGistContext(void); +extern void initGISTstate(GISTSTATE *giststate, Relation index); +extern void freeGISTstate(GISTSTATE *giststate); +extern void gistdentryinit(GISTSTATE *giststate, int nkey, GISTENTRY *e, + Datum k, Relation r, Page pg, OffsetNumber o, + int b, bool l, bool isNull); +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); + +/* gistget.c */ +extern Datum gistgettuple(PG_FUNCTION_ARGS); +extern Datum gistgetmulti(PG_FUNCTION_ARGS); + +#endif /* GIST_PRIVATE_H */ |