PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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 GINNProcs   6
 
#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 DatumGetGinTernaryValue(X)   ((GinTernaryValue)(X))
 
#define GinTernaryValueGetDatum(X)   ((Datum)(X))
 
#define PG_RETURN_GIN_TERNARY_VALUE(x)   return GinTernaryValueGetDatum(x)
 

Typedefs

typedef struct GinStatsData GinStatsData
 
typedef char GinTernaryValue
 

Functions

void ginGetStats (Relation index, GinStatsData *stats)
 
void ginUpdateStats (Relation index, const GinStatsData *stats)
 

Variables

PGDLLIMPORT int GinFuzzySearchLimit
 
int gin_pending_list_limit
 

Macro Definition Documentation

#define DatumGetGinTernaryValue (   X)    ((GinTernaryValue)(X))

Definition at line 64 of file gin.h.

Referenced by directTriConsistentFn(), and shimBoolConsistentFn().

#define GIN_COMPARE_PARTIAL_PROC   5

Definition at line 26 of file gin.h.

Referenced by ginvalidate(), and initGinState().

#define GIN_COMPARE_PROC   1

Definition at line 22 of file gin.h.

Referenced by ginvalidate(), and initGinState().

#define GIN_CONSISTENT_PROC   4

Definition at line 25 of file gin.h.

Referenced by ginvalidate(), and initGinState().

#define GIN_EXTRACTQUERY_PROC   3

Definition at line 24 of file gin.h.

Referenced by gincost_pattern(), ginvalidate(), and initGinState().

#define GIN_EXTRACTVALUE_PROC   2

Definition at line 23 of file gin.h.

Referenced by ginvalidate(), and initGinState().

#define GIN_MAYBE
#define GIN_SEARCH_MODE_DEFAULT   0
#define GIN_SEARCH_MODE_EVERYTHING   3 /* for internal use only */

Definition at line 36 of file gin.h.

Referenced by ginFillScanKey(), ginInitConsistentFunction(), and ginNewScanKey().

#define GIN_SEARCH_MODE_INCLUDE_EMPTY   1

Definition at line 34 of file gin.h.

Referenced by gincost_pattern(), ginFillScanKey(), ginint4_queryextract(), and ginqueryarrayextract().

#define GIN_TRICONSISTENT_PROC   6

Definition at line 27 of file gin.h.

Referenced by ginvalidate(), and initGinState().

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

Definition at line 28 of file gin.h.

Referenced by ginhandler(), and ginvalidate().

#define GinTernaryValueGetDatum (   X)    ((Datum)(X))

Definition at line 65 of file gin.h.

#define PG_RETURN_GIN_TERNARY_VALUE (   x)    return GinTernaryValueGetDatum(x)

Typedef Documentation

Definition at line 57 of file gin.h.

Function Documentation

void ginGetStats ( Relation  index,
GinStatsData stats 
)

Definition at line 632 of file ginutil.c.

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(), and ginNewScanKey().

633 {
634  Buffer metabuffer;
635  Page metapage;
636  GinMetaPageData *metadata;
637 
638  metabuffer = ReadBuffer(index, GIN_METAPAGE_BLKNO);
639  LockBuffer(metabuffer, GIN_SHARE);
640  metapage = BufferGetPage(metabuffer);
641  metadata = GinPageGetMeta(metapage);
642 
643  stats->nPendingPages = metadata->nPendingPages;
644  stats->nTotalPages = metadata->nTotalPages;
645  stats->nEntryPages = metadata->nEntryPages;
646  stats->nDataPages = metadata->nDataPages;
647  stats->nEntries = metadata->nEntries;
648  stats->ginVersion = metadata->ginVersion;
649 
650  UnlockReleaseBuffer(metabuffer);
651 }
BlockNumber nEntryPages
Definition: ginblock.h:79
BlockNumber nEntryPages
Definition: gin.h:45
int64 nEntries
Definition: gin.h:47
BlockNumber nTotalPages
Definition: ginblock.h:78
#define GIN_METAPAGE_BLKNO
Definition: ginblock.h:50
int64 nEntries
Definition: ginblock.h:81
void UnlockReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3332
#define BufferGetPage(buffer)
Definition: bufmgr.h:160
#define GIN_SHARE
Definition: gin_private.h:44
BlockNumber nPendingPages
Definition: gin.h:43
void LockBuffer(Buffer buffer, int mode)
Definition: bufmgr.c:3546
BlockNumber nDataPages
Definition: gin.h:46
Buffer ReadBuffer(Relation reln, BlockNumber blockNum)
Definition: bufmgr.c:594
BlockNumber nTotalPages
Definition: gin.h:44
int32 ginVersion
Definition: ginblock.h:98
int32 ginVersion
Definition: gin.h:48
BlockNumber nDataPages
Definition: ginblock.h:80
#define GinPageGetMeta(p)
Definition: ginblock.h:103
int Buffer
Definition: buf.h:23
Pointer Page
Definition: bufpage.h:74
BlockNumber nPendingPages
Definition: ginblock.h:72
void ginUpdateStats ( Relation  index,
const GinStatsData stats 
)

Definition at line 659 of file ginutil.c.

References BufferGetPage, END_CRIT_SECTION, GIN_EXCLUSIVE, GIN_METAPAGE_BLKNO, GinPageGetMeta, InvalidBlockNumber, LockBuffer(), MarkBufferDirty(), ginxlogUpdateMeta::metadata, GinStatsData::nDataPages, GinMetaPageData::nDataPages, GinStatsData::nEntries, GinMetaPageData::nEntries, GinStatsData::nEntryPages, GinMetaPageData::nEntryPages, ginxlogUpdateMeta::newRightlink, ginxlogUpdateMeta::node, GinStatsData::nTotalPages, GinMetaPageData::nTotalPages, ginxlogUpdateMeta::ntuples, PageSetLSN, ginxlogUpdateMeta::prevTail, RelationData::rd_node, ReadBuffer(), REGBUF_WILL_INIT, RelationNeedsWAL, START_CRIT_SECTION, UnlockReleaseBuffer(), XLOG_GIN_UPDATE_META_PAGE, XLogBeginInsert(), XLogInsert(), XLogRegisterBuffer(), and XLogRegisterData().

Referenced by ginbuild(), and ginvacuumcleanup().

660 {
661  Buffer metabuffer;
662  Page metapage;
663  GinMetaPageData *metadata;
664 
665  metabuffer = ReadBuffer(index, GIN_METAPAGE_BLKNO);
666  LockBuffer(metabuffer, GIN_EXCLUSIVE);
667  metapage = BufferGetPage(metabuffer);
668  metadata = GinPageGetMeta(metapage);
669 
671 
672  metadata->nTotalPages = stats->nTotalPages;
673  metadata->nEntryPages = stats->nEntryPages;
674  metadata->nDataPages = stats->nDataPages;
675  metadata->nEntries = stats->nEntries;
676 
677  MarkBufferDirty(metabuffer);
678 
679  if (RelationNeedsWAL(index))
680  {
681  XLogRecPtr recptr;
682  ginxlogUpdateMeta data;
683 
684  data.node = index->rd_node;
685  data.ntuples = 0;
687  memcpy(&data.metadata, metadata, sizeof(GinMetaPageData));
688 
689  XLogBeginInsert();
690  XLogRegisterData((char *) &data, sizeof(ginxlogUpdateMeta));
691  XLogRegisterBuffer(0, metabuffer, REGBUF_WILL_INIT);
692 
693  recptr = XLogInsert(RM_GIN_ID, XLOG_GIN_UPDATE_META_PAGE);
694  PageSetLSN(metapage, recptr);
695  }
696 
697  UnlockReleaseBuffer(metabuffer);
698 
700 }
BlockNumber nEntryPages
Definition: ginblock.h:79
BlockNumber prevTail
Definition: ginxlog.h:173
BlockNumber nEntryPages
Definition: gin.h:45
RelFileNode node
Definition: ginxlog.h:171
void MarkBufferDirty(Buffer buffer)
Definition: bufmgr.c:1450
void XLogRegisterBuffer(uint8 block_id, Buffer buffer, uint8 flags)
Definition: xloginsert.c:213
#define END_CRIT_SECTION()
Definition: miscadmin.h:133
#define REGBUF_WILL_INIT
Definition: xloginsert.h:32
#define START_CRIT_SECTION()
Definition: miscadmin.h:131
int64 nEntries
Definition: gin.h:47
BlockNumber nTotalPages
Definition: ginblock.h:78
#define GIN_METAPAGE_BLKNO
Definition: ginblock.h:50
int64 nEntries
Definition: ginblock.h:81
void UnlockReleaseBuffer(Buffer buffer)
Definition: bufmgr.c:3332
#define XLOG_GIN_UPDATE_META_PAGE
Definition: ginxlog.h:163
#define BufferGetPage(buffer)
Definition: bufmgr.h:160
BlockNumber newRightlink
Definition: ginxlog.h:174
void XLogRegisterData(char *data, int len)
Definition: xloginsert.c:323
XLogRecPtr XLogInsert(RmgrId rmid, uint8 info)
Definition: xloginsert.c:415
#define GIN_EXCLUSIVE
Definition: gin_private.h:45
void LockBuffer(Buffer buffer, int mode)
Definition: bufmgr.c:3546
BlockNumber nDataPages
Definition: gin.h:46
GinMetaPageData metadata
Definition: ginxlog.h:172
RelFileNode rd_node
Definition: rel.h:85
uint64 XLogRecPtr
Definition: xlogdefs.h:21
Buffer ReadBuffer(Relation reln, BlockNumber blockNum)
Definition: bufmgr.c:594
#define InvalidBlockNumber
Definition: block.h:33
BlockNumber nTotalPages
Definition: gin.h:44
#define RelationNeedsWAL(relation)
Definition: rel.h:505
BlockNumber nDataPages
Definition: ginblock.h:80
#define GinPageGetMeta(p)
Definition: ginblock.h:103
void XLogBeginInsert(void)
Definition: xloginsert.c:120
#define PageSetLSN(page, lsn)
Definition: bufpage.h:364
int Buffer
Definition: buf.h:23
Pointer Page
Definition: bufpage.h:74

Variable Documentation

int gin_pending_list_limit

Definition at line 37 of file ginfast.c.

PGDLLIMPORT int GinFuzzySearchLimit

Definition at line 24 of file ginget.c.

Referenced by startScan().