1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-25 20:23:07 +03:00

Minor tweaking of index special-space definitions so that the various

index types can be reliably distinguished by examining the special space
on an index page.  Per my earlier proposal, plus the realization that
there's no need for btree's vacuum cycle ID to cycle through every possible
16-bit value.  Restricting its range a little costs nearly nothing and
eliminates the possibility of collisions.
Memo to self: remember to make bitmap indexes play along with this scheme,
assuming that patch ever gets accepted.
This commit is contained in:
Tom Lane
2007-04-09 22:04:08 +00:00
parent 485d9ca96f
commit 56218fbc48
9 changed files with 78 additions and 64 deletions

View File

@@ -3,7 +3,7 @@
* header file for postgres inverted index access method implementation.
*
* Copyright (c) 2006, PostgreSQL Global Development Group
* $PostgreSQL: pgsql/src/include/access/gin.h,v 1.10 2007/01/31 15:09:45 teodor Exp $
* $PostgreSQL: pgsql/src/include/access/gin.h,v 1.11 2007/04/09 22:04:04 tgl Exp $
*--------------------------------------------------------------------------
*/
@@ -31,41 +31,27 @@
#define GIN_CONSISTENT_PROC 4
#define GINNProcs 4
typedef XLogRecPtr GinNSN;
/*
* Page opaque data in a inverted index page.
*
* Note: GIN does not include a page ID word as do the other index types.
* This is OK because the opaque data is only 8 bytes and so can be reliably
* distinguished by size. Revisit this if the size ever increases.
*/
typedef struct GinPageOpaqueData
{
uint16 flags;
BlockNumber rightlink; /* next page if any */
OffsetNumber maxoff; /* number entries on GIN_DATA page: number of
* heap ItemPointer on GIN_DATA|GIN_LEAF page
* and number of records on GIN_DATA &
* ~GIN_LEAF page */
BlockNumber rightlink;
uint16 flags; /* see bit definitions below */
} GinPageOpaqueData;
typedef GinPageOpaqueData *GinPageOpaque;
#define GIN_ROOT_BLKNO (0)
typedef struct
{
BlockIdData child_blkno; /* use it instead of BlockNumber to save space
* on page */
ItemPointerData key;
} PostingItem;
#define PostingItemGetBlockNumber(pointer) \
BlockIdGetBlockNumber(&(pointer)->child_blkno)
#define PostingItemSetBlockNumber(pointer, blockNumber) \
BlockIdSet(&((pointer)->child_blkno), (blockNumber))
/*
* Page opaque data in a inverted index page.
*/
#define GIN_DATA (1 << 0)
#define GIN_LEAF (1 << 1)
#define GIN_DELETED (1 << 2)
@@ -98,8 +84,21 @@ typedef struct
#define GinItemPointerGetOffsetNumber(pointer) \
((pointer)->ip_posid)
typedef struct
{
BlockIdData child_blkno; /* use it instead of BlockNumber to save space
* on page */
ItemPointerData key;
} PostingItem;
#define PostingItemGetBlockNumber(pointer) \
BlockIdGetBlockNumber(&(pointer)->child_blkno)
#define PostingItemSetBlockNumber(pointer, blockNumber) \
BlockIdSet(&((pointer)->child_blkno), (blockNumber))
/*
* Support work on IndexTuuple on leaf pages
* Support work on IndexTuple on leaf pages
*/
#define GinGetNPosting(itup) GinItemPointerGetOffsetNumber(&(itup)->t_tid)
#define GinSetNPosting(itup,n) ItemPointerSetOffsetNumber(&(itup)->t_tid,(n))