PostgreSQL Source Code  git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
gist.h File Reference
#include "access/itup.h"
#include "access/stratnum.h"
#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 GIST_OPTIONS_PROC   10
 
#define GIST_SORTSUPPORT_PROC   11
 
#define GIST_STRATNUM_PROC   12
 
#define GISTNProcs   12
 
#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 GISTMaxIndexTupleSize
 
#define GISTMaxIndexKeySize    (GISTMaxIndexTupleSize - MAXALIGN(sizeof(IndexTupleData)))
 
#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)
 
StrategyNumber GistTranslateStratnum (Oid opclass, StrategyNumber strat)
 

Macro Definition Documentation

◆ F_DELETED

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

Definition at line 49 of file gist.h.

◆ F_FOLLOW_RIGHT

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

Definition at line 51 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 52 of file gist.h.

◆ F_LEAF

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

Definition at line 48 of file gist.h.

◆ F_TUPLES_DELETED

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

Definition at line 50 of file gist.h.

◆ GEVHDRSZ

#define GEVHDRSZ   (offsetof(GistEntryVector, vector))

Definition at line 239 of file gist.h.

◆ GIST_COMPRESS_PROC

#define GIST_COMPRESS_PROC   3

Definition at line 33 of file gist.h.

◆ GIST_CONSISTENT_PROC

#define GIST_CONSISTENT_PROC   1

Definition at line 31 of file gist.h.

◆ GIST_DECOMPRESS_PROC

#define GIST_DECOMPRESS_PROC   4

Definition at line 34 of file gist.h.

◆ GIST_DISTANCE_PROC

#define GIST_DISTANCE_PROC   8

Definition at line 38 of file gist.h.

◆ GIST_EQUAL_PROC

#define GIST_EQUAL_PROC   7

Definition at line 37 of file gist.h.

◆ GIST_FETCH_PROC

#define GIST_FETCH_PROC   9

Definition at line 39 of file gist.h.

◆ GIST_LEAF

#define GIST_LEAF (   entry)    (GistPageIsLeaf((entry)->page))

Definition at line 170 of file gist.h.

◆ GIST_OPTIONS_PROC

#define GIST_OPTIONS_PROC   10

Definition at line 40 of file gist.h.

◆ GIST_PAGE_ID

#define GIST_PAGE_ID   0xFF81

Definition at line 111 of file gist.h.

◆ GIST_PENALTY_PROC

#define GIST_PENALTY_PROC   5

Definition at line 35 of file gist.h.

◆ GIST_PICKSPLIT_PROC

#define GIST_PICKSPLIT_PROC   6

Definition at line 36 of file gist.h.

◆ GIST_SORTSUPPORT_PROC

#define GIST_SORTSUPPORT_PROC   11

Definition at line 41 of file gist.h.

◆ GIST_STRATNUM_PROC

#define GIST_STRATNUM_PROC   12

Definition at line 42 of file gist.h.

◆ GIST_UNION_PROC

#define GIST_UNION_PROC   2

Definition at line 32 of file gist.h.

◆ GistBuildLSN

#define GistBuildLSN   ((XLogRecPtr) 1)

Definition at line 69 of file gist.h.

◆ GistClearFollowRight

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

Definition at line 184 of file gist.h.

◆ GistClearPageHasGarbage

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

Definition at line 180 of file gist.h.

◆ GistClearTuplesDeleted

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

Definition at line 176 of file gist.h.

◆ gistentryinit

#define gistentryinit (   e,
  k,
  r,
  pg,
  o,
 
)
Value:
do { (e).key = (k); (e).rel = (r); (e).page = (pg); \
(e).offset = (o); (e).leafkey = (l); } while (0)
e
Definition: preproc-init.c:82

Definition at line 244 of file gist.h.

◆ GistFollowRight

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

Definition at line 182 of file gist.h.

◆ GistMarkFollowRight

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

Definition at line 183 of file gist.h.

◆ GistMarkPageHasGarbage

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

Definition at line 179 of file gist.h.

◆ GistMarkTuplesDeleted

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

Definition at line 175 of file gist.h.

◆ GISTMaxIndexKeySize

#define GISTMaxIndexKeySize    (GISTMaxIndexTupleSize - MAXALIGN(sizeof(IndexTupleData)))

Definition at line 102 of file gist.h.

◆ GISTMaxIndexTupleSize

#define GISTMaxIndexTupleSize
Value:
4 - sizeof(ItemIdData))
#define SizeOfPageHeaderData
Definition: bufpage.h:216
#define MAXALIGN_DOWN(LEN)
Definition: c.h:802

Definition at line 98 of file gist.h.

◆ GISTNProcs

#define GISTNProcs   12

Definition at line 43 of file gist.h.

◆ GistPageGetNSN

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

Definition at line 186 of file gist.h.

◆ GistPageGetOpaque

#define GistPageGetOpaque (   page)    ( (GISTPageOpaque) PageGetSpecialPointer(page) )

Definition at line 167 of file gist.h.

◆ GistPageHasGarbage

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

Definition at line 178 of file gist.h.

◆ GistPageIsDeleted

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

Definition at line 172 of file gist.h.

◆ GistPageIsLeaf

#define GistPageIsLeaf (   page)    ( GistPageGetOpaque(page)->flags & F_LEAF)

Definition at line 169 of file gist.h.

◆ GistPageSetNSN

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

Definition at line 187 of file gist.h.

◆ GistTuplesDeleted

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

Definition at line 174 of file gist.h.

Typedef Documentation

◆ GIST_SPLITVEC

typedef struct GIST_SPLITVEC GIST_SPLITVEC

◆ GISTDeletedPageContents

◆ GISTENTRY

typedef struct GISTENTRY GISTENTRY

◆ GistNSN

Definition at line 62 of file gist.h.

◆ GISTPageOpaque

Definition at line 85 of file gist.h.

◆ GISTPageOpaqueData

◆ PageGistNSN

Definition at line 75 of file gist.h.

Function Documentation

◆ GistPageGetDeleteXid()

static FullTransactionId GistPageGetDeleteXid ( Page  page)
inlinestatic

Definition at line 215 of file gist.h.

218 {
219  Assert(GistPageIsDeleted(page));
220 
221  /* Is the deleteXid field present? */
222  if (((PageHeader) page)->pd_lower >= MAXALIGN(SizeOfPageHeaderData) +
223  offsetof(GISTDeletedPageContents, deleteXid) + sizeof(FullTransactionId))
224  {
225  return ((GISTDeletedPageContents *) PageGetContents(page))->deleteXid;
226  }
227  else
static char * PageGetContents(Page page)
Definition: bufpage.h:257
#define MAXALIGN(LEN)
Definition: c.h:790
#define Assert(condition)
Definition: c.h:837
#define GistPageIsDeleted(page)
Definition: gist.h:172

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

Referenced by gistNewBuffer(), and gistPageRecyclable().

◆ GistPageSetDeleted()

static void GistPageSetDeleted ( Page  page,
FullTransactionId  deletexid 
)
inlinestatic

Definition at line 204 of file gist.h.

207 {
208  Assert(PageIsEmpty(page));
209 
210  GistPageGetOpaque(page)->flags |= F_DELETED;
211  ((PageHeader) page)->pd_lower = MAXALIGN(SizeOfPageHeaderData) + sizeof(GISTDeletedPageContents);
212 
PageHeaderData * PageHeader
Definition: bufpage.h:173
static bool PageIsEmpty(Page page)
Definition: bufpage.h:223
struct GISTDeletedPageContents GISTDeletedPageContents
#define GistPageGetOpaque(page)
Definition: gist.h:167
#define F_DELETED
Definition: gist.h:49

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

Referenced by gistdeletepage(), and gistRedoPageDelete().

◆ GistTranslateStratnum()

StrategyNumber GistTranslateStratnum ( Oid  opclass,
StrategyNumber  strat 
)

Definition at line 1081 of file gistutil.c.

1082 {
1083  Oid opfamily;
1084  Oid opcintype;
1085  Oid funcid;
1086  Datum result;
1087 
1088  /* Look up the opclass family and input datatype. */
1089  if (!get_opclass_opfamily_and_input_type(opclass, &opfamily, &opcintype))
1090  return InvalidStrategy;
1091 
1092  /* Check whether the function is provided. */
1093  funcid = get_opfamily_proc(opfamily, opcintype, opcintype, GIST_STRATNUM_PROC);
1094  if (!OidIsValid(funcid))
1095  return InvalidStrategy;
1096 
1097  /* Ask the translation function */
1098  result = OidFunctionCall1Coll(funcid, InvalidOid, UInt16GetDatum(strat));
1099  return DatumGetUInt16(result);
1100 }
#define OidIsValid(objectId)
Definition: c.h:754
Datum OidFunctionCall1Coll(Oid functionId, Oid collation, Datum arg1)
Definition: fmgr.c:1411
#define GIST_STRATNUM_PROC
Definition: gist.h:42
bool get_opclass_opfamily_and_input_type(Oid opclass, Oid *opfamily, Oid *opcintype)
Definition: lsyscache.c:1235
Oid get_opfamily_proc(Oid opfamily, Oid lefttype, Oid righttype, int16 procnum)
Definition: lsyscache.c:796
uintptr_t Datum
Definition: postgres.h:64
static Datum UInt16GetDatum(uint16 X)
Definition: postgres.h:192
static uint16 DatumGetUInt16(Datum X)
Definition: postgres.h:182
#define InvalidOid
Definition: postgres_ext.h:36
unsigned int Oid
Definition: postgres_ext.h:31
#define InvalidStrategy
Definition: stratnum.h:24

References DatumGetUInt16(), get_opclass_opfamily_and_input_type(), get_opfamily_proc(), GIST_STRATNUM_PROC, InvalidOid, InvalidStrategy, OidFunctionCall1Coll(), OidIsValid, and UInt16GetDatum().

Referenced by ATAddForeignKeyConstraint(), and GetOperatorFromWellKnownStrategy().