PostgreSQL Source Code  git master
gist.h File Reference
#include "access/transam.h"
#include "access/xlog.h"
#include "access/xlogdefs.h"
#include "storage/block.h"
#include "storage/bufpage.h"
#include "utils/relcache.h"
Include dependency graph for gist.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  GISTPageOpaqueData
 
struct  GIST_SPLITVEC
 
struct  GISTENTRY
 
struct  GISTDeletedPageContents
 
struct  GistEntryVector
 

Macros

#define GIST_CONSISTENT_PROC   1
 
#define GIST_UNION_PROC   2
 
#define GIST_COMPRESS_PROC   3
 
#define GIST_DECOMPRESS_PROC   4
 
#define GIST_PENALTY_PROC   5
 
#define GIST_PICKSPLIT_PROC   6
 
#define GIST_EQUAL_PROC   7
 
#define GIST_DISTANCE_PROC   8
 
#define GIST_FETCH_PROC   9
 
#define GISTNProcs   9
 
#define F_LEAF   (1 << 0) /* leaf page */
 
#define F_DELETED   (1 << 1) /* the page has been deleted */
 
#define F_TUPLES_DELETED
 
#define F_FOLLOW_RIGHT   (1 << 3) /* page to the right has no downlink */
 
#define F_HAS_GARBAGE
 
#define GistBuildLSN   ((XLogRecPtr) 1)
 
#define GIST_PAGE_ID   0xFF81
 
#define GistPageGetOpaque(page)   ( (GISTPageOpaque) PageGetSpecialPointer(page) )
 
#define GistPageIsLeaf(page)   ( GistPageGetOpaque(page)->flags & F_LEAF)
 
#define GIST_LEAF(entry)   (GistPageIsLeaf((entry)->page))
 
#define GistPageIsDeleted(page)   ( GistPageGetOpaque(page)->flags & F_DELETED)
 
#define GistTuplesDeleted(page)   ( GistPageGetOpaque(page)->flags & F_TUPLES_DELETED)
 
#define GistMarkTuplesDeleted(page)   ( GistPageGetOpaque(page)->flags |= F_TUPLES_DELETED)
 
#define GistClearTuplesDeleted(page)   ( GistPageGetOpaque(page)->flags &= ~F_TUPLES_DELETED)
 
#define GistPageHasGarbage(page)   ( GistPageGetOpaque(page)->flags & F_HAS_GARBAGE)
 
#define GistMarkPageHasGarbage(page)   ( GistPageGetOpaque(page)->flags |= F_HAS_GARBAGE)
 
#define GistClearPageHasGarbage(page)   ( GistPageGetOpaque(page)->flags &= ~F_HAS_GARBAGE)
 
#define GistFollowRight(page)   ( GistPageGetOpaque(page)->flags & F_FOLLOW_RIGHT)
 
#define GistMarkFollowRight(page)   ( GistPageGetOpaque(page)->flags |= F_FOLLOW_RIGHT)
 
#define GistClearFollowRight(page)   ( GistPageGetOpaque(page)->flags &= ~F_FOLLOW_RIGHT)
 
#define GistPageGetNSN(page)   ( PageXLogRecPtrGet(GistPageGetOpaque(page)->nsn))
 
#define GistPageSetNSN(page, val)   ( PageXLogRecPtrSet(GistPageGetOpaque(page)->nsn, val))
 
#define GEVHDRSZ   (offsetof(GistEntryVector, vector))
 
#define gistentryinit(e, k, r, pg, o, l)
 

Typedefs

typedef XLogRecPtr GistNSN
 
typedef PageXLogRecPtr PageGistNSN
 
typedef struct GISTPageOpaqueData GISTPageOpaqueData
 
typedef GISTPageOpaqueDataGISTPageOpaque
 
typedef struct GIST_SPLITVEC GIST_SPLITVEC
 
typedef struct GISTENTRY GISTENTRY
 
typedef struct GISTDeletedPageContents GISTDeletedPageContents
 

Functions

static void GistPageSetDeleted (Page page, FullTransactionId deletexid)
 
static FullTransactionId GistPageGetDeleteXid (Page page)
 

Macro Definition Documentation

◆ F_DELETED

#define F_DELETED   (1 << 1) /* the page has been deleted */

Definition at line 44 of file gist.h.

Referenced by GistPageSetDeleted().

◆ F_FOLLOW_RIGHT

#define F_FOLLOW_RIGHT   (1 << 3) /* page to the right has no downlink */

Definition at line 47 of file gist.h.

◆ F_HAS_GARBAGE

#define F_HAS_GARBAGE
Value:
(1 << 4) /* some tuples on the page are dead,
* but not deleted yet */

Definition at line 48 of file gist.h.

◆ F_LEAF

#define F_LEAF   (1 << 0) /* leaf page */

Definition at line 43 of file gist.h.

Referenced by gistbuild(), gistbuildempty(), gistplacetopage(), and gistRedoPageSplitRecord().

◆ F_TUPLES_DELETED

#define F_TUPLES_DELETED
Value:
(1 << 2) /* some tuples on the page were
* deleted */

Definition at line 45 of file gist.h.

◆ GEVHDRSZ

#define GEVHDRSZ   (offsetof(GistEntryVector, vector))

Definition at line 210 of file gist.h.

Referenced by genericPickSplit(), gistMakeUnionItVec(), gistMakeUnionKey(), and gistSplitByKey().

◆ GIST_COMPRESS_PROC

#define GIST_COMPRESS_PROC   3

Definition at line 31 of file gist.h.

Referenced by gistcanreturn(), gistproperty(), gistvalidate(), and initGISTstate().

◆ GIST_CONSISTENT_PROC

#define GIST_CONSISTENT_PROC   1

Definition at line 29 of file gist.h.

Referenced by gistvalidate(), and initGISTstate().

◆ GIST_DECOMPRESS_PROC

#define GIST_DECOMPRESS_PROC   4

Definition at line 32 of file gist.h.

Referenced by gistvalidate(), and initGISTstate().

◆ GIST_DISTANCE_PROC

#define GIST_DISTANCE_PROC   8

Definition at line 36 of file gist.h.

Referenced by gistproperty(), gistrescan(), gistvalidate(), and initGISTstate().

◆ GIST_EQUAL_PROC

#define GIST_EQUAL_PROC   7

Definition at line 35 of file gist.h.

Referenced by gistvalidate(), and initGISTstate().

◆ GIST_FETCH_PROC

#define GIST_FETCH_PROC   9

Definition at line 37 of file gist.h.

Referenced by gistcanreturn(), gistproperty(), gistvalidate(), and initGISTstate().

◆ GIST_LEAF

◆ GIST_PAGE_ID

#define GIST_PAGE_ID   0xFF81

Definition at line 82 of file gist.h.

Referenced by GISTInitBuffer().

◆ GIST_PENALTY_PROC

#define GIST_PENALTY_PROC   5

Definition at line 33 of file gist.h.

Referenced by gistvalidate(), and initGISTstate().

◆ GIST_PICKSPLIT_PROC

#define GIST_PICKSPLIT_PROC   6

Definition at line 34 of file gist.h.

Referenced by gistvalidate(), and initGISTstate().

◆ GIST_UNION_PROC

#define GIST_UNION_PROC   2

Definition at line 30 of file gist.h.

Referenced by gistvalidate(), and initGISTstate().

◆ GistBuildLSN

#define GistBuildLSN   ((XLogRecPtr) 1)

Definition at line 58 of file gist.h.

Referenced by gistbuild(), and gistplacetopage().

◆ GistClearFollowRight

#define GistClearFollowRight (   page)    ( GistPageGetOpaque(page)->flags &= ~F_FOLLOW_RIGHT)

Definition at line 155 of file gist.h.

Referenced by gistplacetopage(), gistRedoClearFollowRight(), and gistRedoPageSplitRecord().

◆ GistClearPageHasGarbage

#define GistClearPageHasGarbage (   page)    ( GistPageGetOpaque(page)->flags &= ~F_HAS_GARBAGE)

Definition at line 151 of file gist.h.

Referenced by gist_mask(), gistprunepage(), and gistRedoDeleteRecord().

◆ GistClearTuplesDeleted

#define GistClearTuplesDeleted (   page)    ( GistPageGetOpaque(page)->flags &= ~F_TUPLES_DELETED)

Definition at line 147 of file gist.h.

◆ gistentryinit

◆ GistFollowRight

#define GistFollowRight (   page)    ( GistPageGetOpaque(page)->flags & F_FOLLOW_RIGHT)

◆ GistMarkFollowRight

#define GistMarkFollowRight (   page)    ( GistPageGetOpaque(page)->flags |= F_FOLLOW_RIGHT)

Definition at line 154 of file gist.h.

Referenced by gist_mask(), gistplacetopage(), and gistRedoPageSplitRecord().

◆ GistMarkPageHasGarbage

#define GistMarkPageHasGarbage (   page)    ( GistPageGetOpaque(page)->flags |= F_HAS_GARBAGE)

Definition at line 150 of file gist.h.

Referenced by gistkillitems().

◆ GistMarkTuplesDeleted

#define GistMarkTuplesDeleted (   page)    ( GistPageGetOpaque(page)->flags |= F_TUPLES_DELETED)

Definition at line 146 of file gist.h.

Referenced by gistRedoDeleteRecord(), gistRedoPageUpdateRecord(), and gistvacuumpage().

◆ GISTNProcs

#define GISTNProcs   9

Definition at line 38 of file gist.h.

Referenced by gisthandler(), and gistvalidate().

◆ GistPageGetNSN

#define GistPageGetNSN (   page)    ( PageXLogRecPtrGet(GistPageGetOpaque(page)->nsn))

Definition at line 157 of file gist.h.

Referenced by gistdoinsert(), gistFindPath(), gistplacetopage(), gistScanPage(), and gistvacuumpage().

◆ GistPageGetOpaque

◆ GistPageHasGarbage

#define GistPageHasGarbage (   page)    ( GistPageGetOpaque(page)->flags & F_HAS_GARBAGE)

Definition at line 149 of file gist.h.

Referenced by gistplacetopage().

◆ GistPageIsDeleted

#define GistPageIsDeleted (   page)    ( GistPageGetOpaque(page)->flags & F_DELETED)

◆ GistPageIsLeaf

◆ GistPageSetNSN

#define GistPageSetNSN (   page,
  val 
)    ( PageXLogRecPtrSet(GistPageGetOpaque(page)->nsn, val))

◆ GistTuplesDeleted

#define GistTuplesDeleted (   page)    ( GistPageGetOpaque(page)->flags & F_TUPLES_DELETED)

Definition at line 145 of file gist.h.

Typedef Documentation

◆ GIST_SPLITVEC

typedef struct GIST_SPLITVEC GIST_SPLITVEC

◆ GISTDeletedPageContents

◆ GISTENTRY

typedef struct GISTENTRY GISTENTRY

◆ GistNSN

Definition at line 51 of file gist.h.

◆ GISTPageOpaque

Definition at line 74 of file gist.h.

◆ GISTPageOpaqueData

◆ PageGistNSN

Definition at line 64 of file gist.h.

Function Documentation

◆ GistPageGetDeleteXid()

static FullTransactionId GistPageGetDeleteXid ( Page  page)
inlinestatic

Definition at line 186 of file gist.h.

References Assert, FirstNormalTransactionId, FullTransactionIdFromEpochAndXid(), GistPageIsDeleted, MAXALIGN, offsetof, PageGetContents, and SizeOfPageHeaderData.

Referenced by gistNewBuffer(), and gistPageRecyclable().

187 {
188  Assert(GistPageIsDeleted(page));
189 
190  /* Is the deleteXid field present? */
191  if (((PageHeader) page)->pd_lower >= MAXALIGN(SizeOfPageHeaderData) +
192  offsetof(GISTDeletedPageContents, deleteXid) + sizeof(FullTransactionId))
193  {
194  return ((GISTDeletedPageContents *) PageGetContents(page))->deleteXid;
195  }
196  else
198 }
#define GistPageIsDeleted(page)
Definition: gist.h:143
#define SizeOfPageHeaderData
Definition: bufpage.h:216
#define FirstNormalTransactionId
Definition: transam.h:34
#define PageGetContents(page)
Definition: bufpage.h:246
#define Assert(condition)
Definition: c.h:732
static FullTransactionId FullTransactionIdFromEpochAndXid(uint32 epoch, TransactionId xid)
Definition: transam.h:65
#define MAXALIGN(LEN)
Definition: c.h:685
#define offsetof(type, field)
Definition: c.h:655

◆ GistPageSetDeleted()

static void GistPageSetDeleted ( Page  page,
FullTransactionId  deletexid 
)
inlinestatic

Definition at line 175 of file gist.h.

References Assert, F_DELETED, GistPageGetOpaque, MAXALIGN, PageGetContents, PageIsEmpty, and SizeOfPageHeaderData.

Referenced by gistdeletepage(), and gistRedoPageDelete().

176 {
177  Assert(PageIsEmpty(page));
178 
179  GistPageGetOpaque(page)->flags |= F_DELETED;
180  ((PageHeader) page)->pd_lower = MAXALIGN(SizeOfPageHeaderData) + sizeof(GISTDeletedPageContents);
181 
182  ((GISTDeletedPageContents *) PageGetContents(page))->deleteXid = deletexid;
183 }
#define PageIsEmpty(page)
Definition: bufpage.h:222
#define SizeOfPageHeaderData
Definition: bufpage.h:216
#define PageGetContents(page)
Definition: bufpage.h:246
#define GistPageGetOpaque(page)
Definition: gist.h:138
PageHeaderData * PageHeader
Definition: bufpage.h:166
struct GISTDeletedPageContents GISTDeletedPageContents
#define Assert(condition)
Definition: c.h:732
#define MAXALIGN(LEN)
Definition: c.h:685
#define F_DELETED
Definition: gist.h:44