PostgreSQL Source Code  git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
gin.h File Reference
#include "access/xlogreader.h"
#include "lib/stringinfo.h"
#include "storage/block.h"
#include "utils/relcache.h"
Include dependency graph for gin.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  GinStatsData
 

Macros

#define GIN_COMPARE_PROC   1
 
#define GIN_EXTRACTVALUE_PROC   2
 
#define GIN_EXTRACTQUERY_PROC   3
 
#define GIN_CONSISTENT_PROC   4
 
#define GIN_COMPARE_PARTIAL_PROC   5
 
#define GIN_TRICONSISTENT_PROC   6
 
#define GIN_OPTIONS_PROC   7
 
#define GINNProcs   7
 
#define GIN_SEARCH_MODE_DEFAULT   0
 
#define GIN_SEARCH_MODE_INCLUDE_EMPTY   1
 
#define GIN_SEARCH_MODE_ALL   2
 
#define GIN_SEARCH_MODE_EVERYTHING   3 /* for internal use only */
 
#define GIN_FALSE   0 /* item is not present / does not match */
 
#define GIN_TRUE   1 /* item is present / matches */
 
#define GIN_MAYBE
 
#define PG_RETURN_GIN_TERNARY_VALUE(x)   return GinTernaryValueGetDatum(x)
 

Typedefs

typedef struct GinStatsData GinStatsData
 
typedef char GinTernaryValue
 

Functions

 StaticAssertDecl (sizeof(GinTernaryValue)==sizeof(bool), "sizes of GinTernaryValue and bool are not equal")
 
static GinTernaryValue DatumGetGinTernaryValue (Datum X)
 
static Datum GinTernaryValueGetDatum (GinTernaryValue X)
 
void ginGetStats (Relation index, GinStatsData *stats)
 
void ginUpdateStats (Relation index, const GinStatsData *stats, bool is_build)
 

Variables

PGDLLIMPORT int GinFuzzySearchLimit
 
PGDLLIMPORT int gin_pending_list_limit
 

Macro Definition Documentation

◆ GIN_COMPARE_PARTIAL_PROC

#define GIN_COMPARE_PARTIAL_PROC   5

Definition at line 26 of file gin.h.

◆ GIN_COMPARE_PROC

#define GIN_COMPARE_PROC   1

Definition at line 22 of file gin.h.

◆ GIN_CONSISTENT_PROC

#define GIN_CONSISTENT_PROC   4

Definition at line 25 of file gin.h.

◆ GIN_EXTRACTQUERY_PROC

#define GIN_EXTRACTQUERY_PROC   3

Definition at line 24 of file gin.h.

◆ GIN_EXTRACTVALUE_PROC

#define GIN_EXTRACTVALUE_PROC   2

Definition at line 23 of file gin.h.

◆ GIN_FALSE

#define GIN_FALSE   0 /* item is not present / does not match */

Definition at line 63 of file gin.h.

◆ GIN_MAYBE

#define GIN_MAYBE
Value:
2 /* don't know if item is present / don't know
* if matches */

Definition at line 65 of file gin.h.

◆ GIN_OPTIONS_PROC

#define GIN_OPTIONS_PROC   7

Definition at line 28 of file gin.h.

◆ GIN_SEARCH_MODE_ALL

#define GIN_SEARCH_MODE_ALL   2

Definition at line 36 of file gin.h.

◆ GIN_SEARCH_MODE_DEFAULT

#define GIN_SEARCH_MODE_DEFAULT   0

Definition at line 34 of file gin.h.

◆ GIN_SEARCH_MODE_EVERYTHING

#define GIN_SEARCH_MODE_EVERYTHING   3 /* for internal use only */

Definition at line 37 of file gin.h.

◆ GIN_SEARCH_MODE_INCLUDE_EMPTY

#define GIN_SEARCH_MODE_INCLUDE_EMPTY   1

Definition at line 35 of file gin.h.

◆ GIN_TRICONSISTENT_PROC

#define GIN_TRICONSISTENT_PROC   6

Definition at line 27 of file gin.h.

◆ GIN_TRUE

#define GIN_TRUE   1 /* item is present / matches */

Definition at line 64 of file gin.h.

◆ GINNProcs

#define GINNProcs   7

Definition at line 29 of file gin.h.

◆ PG_RETURN_GIN_TERNARY_VALUE

#define PG_RETURN_GIN_TERNARY_VALUE (   x)    return GinTernaryValueGetDatum(x)

Definition at line 79 of file gin.h.

Typedef Documentation

◆ GinStatsData

typedef struct GinStatsData GinStatsData

◆ GinTernaryValue

typedef char GinTernaryValue

Definition at line 58 of file gin.h.

Function Documentation

◆ DatumGetGinTernaryValue()

static GinTernaryValue DatumGetGinTernaryValue ( Datum  X)
inlinestatic

Definition at line 68 of file gin.h.

70 {
71  return (GinTernaryValue) X;
char GinTernaryValue
Definition: gin.h:58

Referenced by directTriConsistentFn(), and shimBoolConsistentFn().

◆ ginGetStats()

void ginGetStats ( Relation  index,
GinStatsData stats 
)

Definition at line 624 of file ginutil.c.

625 {
626  Buffer metabuffer;
627  Page metapage;
628  GinMetaPageData *metadata;
629 
630  metabuffer = ReadBuffer(index, GIN_METAPAGE_BLKNO);
631  LockBuffer(metabuffer, GIN_SHARE);
632  metapage = BufferGetPage(metabuffer);
633  metadata = GinPageGetMeta(metapage);
634 
635  stats->nPendingPages = metadata->nPendingPages;
636  stats->nTotalPages = metadata->nTotalPages;
637  stats->nEntryPages = metadata->nEntryPages;
638  stats->nDataPages = metadata->nDataPages;
639  stats->nEntries = metadata->nEntries;
640  stats->ginVersion = metadata->ginVersion;
641 
642  UnlockReleaseBuffer(metabuffer);
643 }
int Buffer
Definition: buf.h:23
void UnlockReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:4941
void LockBuffer(Buffer buffer, int mode)
Definition: bufmgr.c:5158
Buffer ReadBuffer(Relation reln, BlockNumber blockNum)
Definition: bufmgr.c:746
static Page BufferGetPage(Buffer buffer)
Definition: bufmgr.h:400
Pointer Page
Definition: bufpage.h:81
#define GIN_SHARE
Definition: gin_private.h:50
#define GIN_METAPAGE_BLKNO
Definition: ginblock.h:51
#define GinPageGetMeta(p)
Definition: ginblock.h:104
int64 nEntries
Definition: ginblock.h:82
int32 ginVersion
Definition: ginblock.h:99
BlockNumber nEntryPages
Definition: ginblock.h:80
BlockNumber nPendingPages
Definition: ginblock.h:73
BlockNumber nTotalPages
Definition: ginblock.h:79
BlockNumber nDataPages
Definition: ginblock.h:81
BlockNumber nDataPages
Definition: gin.h:47
BlockNumber nPendingPages
Definition: gin.h:44
BlockNumber nEntryPages
Definition: gin.h:46
int64 nEntries
Definition: gin.h:48
BlockNumber nTotalPages
Definition: gin.h:45
int32 ginVersion
Definition: gin.h:49
Definition: type.h:95

References BufferGetPage(), GIN_METAPAGE_BLKNO, GIN_SHARE, GinPageGetMeta, GinStatsData::ginVersion, GinMetaPageData::ginVersion, LockBuffer(), GinStatsData::nDataPages, GinMetaPageData::nDataPages, GinStatsData::nEntries, GinMetaPageData::nEntries, GinStatsData::nEntryPages, GinMetaPageData::nEntryPages, GinStatsData::nPendingPages, GinMetaPageData::nPendingPages, GinStatsData::nTotalPages, GinMetaPageData::nTotalPages, ReadBuffer(), and UnlockReleaseBuffer().

Referenced by gincostestimate().

◆ GinTernaryValueGetDatum()

static Datum GinTernaryValueGetDatum ( GinTernaryValue  X)
inlinestatic

Definition at line 74 of file gin.h.

76 {
77  return (Datum) X;
uintptr_t Datum
Definition: postgres.h:64

◆ ginUpdateStats()

void ginUpdateStats ( Relation  index,
const GinStatsData stats,
bool  is_build 
)

Definition at line 651 of file ginutil.c.

652 {
653  Buffer metabuffer;
654  Page metapage;
655  GinMetaPageData *metadata;
656 
657  metabuffer = ReadBuffer(index, GIN_METAPAGE_BLKNO);
658  LockBuffer(metabuffer, GIN_EXCLUSIVE);
659  metapage = BufferGetPage(metabuffer);
660  metadata = GinPageGetMeta(metapage);
661 
663 
664  metadata->nTotalPages = stats->nTotalPages;
665  metadata->nEntryPages = stats->nEntryPages;
666  metadata->nDataPages = stats->nDataPages;
667  metadata->nEntries = stats->nEntries;
668 
669  /*
670  * Set pd_lower just past the end of the metadata. This is essential,
671  * because without doing so, metadata will be lost if xlog.c compresses
672  * the page. (We must do this here because pre-v11 versions of PG did not
673  * set the metapage's pd_lower correctly, so a pg_upgraded index might
674  * contain the wrong value.)
675  */
676  ((PageHeader) metapage)->pd_lower =
677  ((char *) metadata + sizeof(GinMetaPageData)) - (char *) metapage;
678 
679  MarkBufferDirty(metabuffer);
680 
681  if (RelationNeedsWAL(index) && !is_build)
682  {
683  XLogRecPtr recptr;
685 
686  data.locator = index->rd_locator;
687  data.ntuples = 0;
688  data.newRightlink = data.prevTail = InvalidBlockNumber;
689  memcpy(&data.metadata, metadata, sizeof(GinMetaPageData));
690 
691  XLogBeginInsert();
692  XLogRegisterData((char *) &data, sizeof(ginxlogUpdateMeta));
694 
695  recptr = XLogInsert(RM_GIN_ID, XLOG_GIN_UPDATE_META_PAGE);
696  PageSetLSN(metapage, recptr);
697  }
698 
699  UnlockReleaseBuffer(metabuffer);
700 
702 }
#define InvalidBlockNumber
Definition: block.h:33
void MarkBufferDirty(Buffer buffer)
Definition: bufmgr.c:2532
PageHeaderData * PageHeader
Definition: bufpage.h:173
static void PageSetLSN(Page page, XLogRecPtr lsn)
Definition: bufpage.h:391
#define GIN_EXCLUSIVE
Definition: gin_private.h:51
#define XLOG_GIN_UPDATE_META_PAGE
Definition: ginxlog.h:162
#define START_CRIT_SECTION()
Definition: miscadmin.h:149
#define END_CRIT_SECTION()
Definition: miscadmin.h:151
const void * data
#define RelationNeedsWAL(relation)
Definition: rel.h:628
uint64 XLogRecPtr
Definition: xlogdefs.h:21
XLogRecPtr XLogInsert(RmgrId rmid, uint8 info)
Definition: xloginsert.c:474
void XLogRegisterData(const char *data, uint32 len)
Definition: xloginsert.c:364
void XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags)
Definition: xloginsert.c:242
void XLogBeginInsert(void)
Definition: xloginsert.c:149
#define REGBUF_STANDARD
Definition: xloginsert.h:34
#define REGBUF_WILL_INIT
Definition: xloginsert.h:33

References BufferGetPage(), data, END_CRIT_SECTION, GIN_EXCLUSIVE, GIN_METAPAGE_BLKNO, GinPageGetMeta, InvalidBlockNumber, LockBuffer(), MarkBufferDirty(), GinStatsData::nDataPages, GinMetaPageData::nDataPages, GinStatsData::nEntries, GinMetaPageData::nEntries, GinStatsData::nEntryPages, GinMetaPageData::nEntryPages, GinStatsData::nTotalPages, GinMetaPageData::nTotalPages, PageSetLSN(), ReadBuffer(), REGBUF_STANDARD, REGBUF_WILL_INIT, RelationNeedsWAL, START_CRIT_SECTION, UnlockReleaseBuffer(), XLOG_GIN_UPDATE_META_PAGE, XLogBeginInsert(), XLogInsert(), XLogRegisterBuffer(), and XLogRegisterData().

Referenced by ginbuild(), and ginvacuumcleanup().

◆ StaticAssertDecl()

StaticAssertDecl ( sizeof(GinTernaryValue = =sizeof(bool),
"sizes of GinTernaryValue and bool are not equal  
)

Variable Documentation

◆ gin_pending_list_limit

PGDLLIMPORT int gin_pending_list_limit
extern

Definition at line 39 of file ginfast.c.

◆ GinFuzzySearchLimit

PGDLLIMPORT int GinFuzzySearchLimit
extern

Definition at line 27 of file ginget.c.

Referenced by startScan().