#include "access/xlog.h"
#include "storage/block.h"
#include "utils/relcache.h"
Go to the source code of this file.
Data Structures | |
struct | GinStatsData |
Defines | |
#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 | GINNProcs 5 |
#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 |
Typedefs | |
typedef struct GinStatsData | GinStatsData |
Functions | |
void | ginGetStats (Relation index, GinStatsData *stats) |
void | ginUpdateStats (Relation index, const GinStatsData *stats) |
void | gin_redo (XLogRecPtr lsn, XLogRecord *record) |
void | gin_desc (StringInfo buf, uint8 xl_info, char *rec) |
void | gin_xlog_startup (void) |
void | gin_xlog_cleanup (void) |
bool | gin_safe_restartpoint (void) |
Variables | |
PGDLLIMPORT int | GinFuzzySearchLimit |
#define GIN_COMPARE_PARTIAL_PROC 5 |
Definition at line 25 of file gin.h.
Referenced by initGinState().
#define GIN_COMPARE_PROC 1 |
Definition at line 21 of file gin.h.
Referenced by initGinState().
#define GIN_CONSISTENT_PROC 4 |
Definition at line 24 of file gin.h.
Referenced by initGinState().
#define GIN_EXTRACTQUERY_PROC 3 |
Definition at line 23 of file gin.h.
Referenced by gincost_pattern(), and initGinState().
#define GIN_EXTRACTVALUE_PROC 2 |
Definition at line 22 of file gin.h.
Referenced by initGinState().
#define GIN_SEARCH_MODE_ALL 2 |
Definition at line 33 of file gin.h.
Referenced by collectMatchBitmap(), collectMatchesForHeapRow(), ginFillScanKey(), and ginNewScanKey().
#define GIN_SEARCH_MODE_DEFAULT 0 |
Definition at line 31 of file gin.h.
Referenced by gincost_pattern(), ginFillScanKey(), and ginNewScanKey().
#define GIN_SEARCH_MODE_EVERYTHING 3 |
Definition at line 34 of file gin.h.
Referenced by callConsistentFn(), ginFillScanKey(), and ginNewScanKey().
#define GIN_SEARCH_MODE_INCLUDE_EMPTY 1 |
Definition at line 32 of file gin.h.
Referenced by gincost_pattern(), and ginFillScanKey().
typedef struct GinStatsData GinStatsData |
void gin_desc | ( | StringInfo | buf, | |
uint8 | xl_info, | |||
char * | rec | |||
) |
Definition at line 29 of file gindesc.c.
References appendStringInfo(), desc_node(), GIN_METAPAGE_BLKNO, GIN_ROOT_BLKNO, XLOG_GIN_CREATE_INDEX, XLOG_GIN_CREATE_PTREE, XLOG_GIN_DELETE_LISTPAGE, XLOG_GIN_DELETE_PAGE, XLOG_GIN_INSERT, XLOG_GIN_INSERT_LISTPAGE, XLOG_GIN_SPLIT, XLOG_GIN_UPDATE_META_PAGE, and XLOG_GIN_VACUUM_PAGE.
{ uint8 info = xl_info & ~XLR_INFO_MASK; switch (info) { case XLOG_GIN_CREATE_INDEX: appendStringInfo(buf, "Create index, "); desc_node(buf, *(RelFileNode *) rec, GIN_ROOT_BLKNO); break; case XLOG_GIN_CREATE_PTREE: appendStringInfo(buf, "Create posting tree, "); desc_node(buf, ((ginxlogCreatePostingTree *) rec)->node, ((ginxlogCreatePostingTree *) rec)->blkno); break; case XLOG_GIN_INSERT: appendStringInfo(buf, "Insert item, "); desc_node(buf, ((ginxlogInsert *) rec)->node, ((ginxlogInsert *) rec)->blkno); appendStringInfo(buf, " offset: %u nitem: %u isdata: %c isleaf %c isdelete %c updateBlkno:%u", ((ginxlogInsert *) rec)->offset, ((ginxlogInsert *) rec)->nitem, (((ginxlogInsert *) rec)->isData) ? 'T' : 'F', (((ginxlogInsert *) rec)->isLeaf) ? 'T' : 'F', (((ginxlogInsert *) rec)->isDelete) ? 'T' : 'F', ((ginxlogInsert *) rec)->updateBlkno); break; case XLOG_GIN_SPLIT: appendStringInfo(buf, "Page split, "); desc_node(buf, ((ginxlogSplit *) rec)->node, ((ginxlogSplit *) rec)->lblkno); appendStringInfo(buf, " isrootsplit: %c", (((ginxlogSplit *) rec)->isRootSplit) ? 'T' : 'F'); break; case XLOG_GIN_VACUUM_PAGE: appendStringInfo(buf, "Vacuum page, "); desc_node(buf, ((ginxlogVacuumPage *) rec)->node, ((ginxlogVacuumPage *) rec)->blkno); break; case XLOG_GIN_DELETE_PAGE: appendStringInfo(buf, "Delete page, "); desc_node(buf, ((ginxlogDeletePage *) rec)->node, ((ginxlogDeletePage *) rec)->blkno); break; case XLOG_GIN_UPDATE_META_PAGE: appendStringInfo(buf, "Update metapage, "); desc_node(buf, ((ginxlogUpdateMeta *) rec)->node, GIN_METAPAGE_BLKNO); break; case XLOG_GIN_INSERT_LISTPAGE: appendStringInfo(buf, "Insert new list page, "); desc_node(buf, ((ginxlogInsertListPage *) rec)->node, ((ginxlogInsertListPage *) rec)->blkno); break; case XLOG_GIN_DELETE_LISTPAGE: appendStringInfo(buf, "Delete list pages (%d), ", ((ginxlogDeleteListPages *) rec)->ndeleted); desc_node(buf, ((ginxlogDeleteListPages *) rec)->node, GIN_METAPAGE_BLKNO); break; default: appendStringInfo(buf, "unknown gin op code %u", info); break; } }
void gin_redo | ( | XLogRecPtr | lsn, | |
XLogRecord * | record | |||
) |
Definition at line 705 of file ginxlog.c.
References elog, ginRedoCreateIndex(), ginRedoCreatePTree(), ginRedoDeleteListPages(), ginRedoDeletePage(), ginRedoInsert(), ginRedoInsertListPage(), ginRedoSplit(), ginRedoUpdateMetapage(), ginRedoVacuumPage(), MemoryContextReset(), MemoryContextSwitchTo(), PANIC, XLogRecord::xl_info, XLOG_GIN_CREATE_INDEX, XLOG_GIN_CREATE_PTREE, XLOG_GIN_DELETE_LISTPAGE, XLOG_GIN_DELETE_PAGE, XLOG_GIN_INSERT, XLOG_GIN_INSERT_LISTPAGE, XLOG_GIN_SPLIT, XLOG_GIN_UPDATE_META_PAGE, and XLOG_GIN_VACUUM_PAGE.
{ uint8 info = record->xl_info & ~XLR_INFO_MASK; /* * GIN indexes do not require any conflict processing. NB: If we ever * implement a similar optimization as we have in b-tree, and remove * killed tuples outside VACUUM, we'll need to handle that here. */ topCtx = MemoryContextSwitchTo(opCtx); switch (info) { case XLOG_GIN_CREATE_INDEX: ginRedoCreateIndex(lsn, record); break; case XLOG_GIN_CREATE_PTREE: ginRedoCreatePTree(lsn, record); break; case XLOG_GIN_INSERT: ginRedoInsert(lsn, record); break; case XLOG_GIN_SPLIT: ginRedoSplit(lsn, record); break; case XLOG_GIN_VACUUM_PAGE: ginRedoVacuumPage(lsn, record); break; case XLOG_GIN_DELETE_PAGE: ginRedoDeletePage(lsn, record); break; case XLOG_GIN_UPDATE_META_PAGE: ginRedoUpdateMetapage(lsn, record); break; case XLOG_GIN_INSERT_LISTPAGE: ginRedoInsertListPage(lsn, record); break; case XLOG_GIN_DELETE_LISTPAGE: ginRedoDeleteListPages(lsn, record); break; default: elog(PANIC, "gin_redo: unknown op code %u", info); } MemoryContextSwitchTo(topCtx); MemoryContextReset(opCtx); }
bool gin_safe_restartpoint | ( | void | ) |
Definition at line 850 of file ginxlog.c.
{ if (incomplete_splits) return false; return true; }
void gin_xlog_cleanup | ( | void | ) |
Definition at line 829 of file ginxlog.c.
References ginContinueSplit(), lfirst, MemoryContextDelete(), MemoryContextReset(), and MemoryContextSwitchTo().
{ ListCell *l; MemoryContext topCtx; topCtx = MemoryContextSwitchTo(opCtx); foreach(l, incomplete_splits) { ginIncompleteSplit *split = (ginIncompleteSplit *) lfirst(l); ginContinueSplit(split); MemoryContextReset(opCtx); } MemoryContextSwitchTo(topCtx); MemoryContextDelete(opCtx); incomplete_splits = NIL; }
void gin_xlog_startup | ( | void | ) |
Definition at line 753 of file ginxlog.c.
References ALLOCSET_DEFAULT_INITSIZE, ALLOCSET_DEFAULT_MAXSIZE, ALLOCSET_DEFAULT_MINSIZE, AllocSetContextCreate(), and CurrentMemoryContext.
{ incomplete_splits = NIL; opCtx = AllocSetContextCreate(CurrentMemoryContext, "GIN recovery temporary context", ALLOCSET_DEFAULT_MINSIZE, ALLOCSET_DEFAULT_INITSIZE, ALLOCSET_DEFAULT_MAXSIZE); }
void ginGetStats | ( | Relation | index, | |
GinStatsData * | stats | |||
) |
Definition at line 531 of file ginutil.c.
References BufferGetPage, GIN_METAPAGE_BLKNO, GIN_SHARE, GinPageGetMeta, GinMetaPageData::ginVersion, GinStatsData::ginVersion, LockBuffer(), GinMetaPageData::nDataPages, GinStatsData::nDataPages, GinMetaPageData::nEntries, GinStatsData::nEntries, GinMetaPageData::nEntryPages, GinStatsData::nEntryPages, GinMetaPageData::nPendingPages, GinStatsData::nPendingPages, GinMetaPageData::nTotalPages, GinStatsData::nTotalPages, ReadBuffer(), and UnlockReleaseBuffer().
Referenced by gincostestimate(), and ginNewScanKey().
{ Buffer metabuffer; Page metapage; GinMetaPageData *metadata; metabuffer = ReadBuffer(index, GIN_METAPAGE_BLKNO); LockBuffer(metabuffer, GIN_SHARE); metapage = BufferGetPage(metabuffer); metadata = GinPageGetMeta(metapage); stats->nPendingPages = metadata->nPendingPages; stats->nTotalPages = metadata->nTotalPages; stats->nEntryPages = metadata->nEntryPages; stats->nDataPages = metadata->nDataPages; stats->nEntries = metadata->nEntries; stats->ginVersion = metadata->ginVersion; UnlockReleaseBuffer(metabuffer); }
void ginUpdateStats | ( | Relation | index, | |
const GinStatsData * | stats | |||
) |
Definition at line 558 of file ginutil.c.
References XLogRecData::buffer, BufferGetPage, XLogRecData::data, END_CRIT_SECTION, GIN_EXCLUSIVE, GIN_METAPAGE_BLKNO, GinPageGetMeta, XLogRecData::len, LockBuffer(), MarkBufferDirty(), ginxlogUpdateMeta::metadata, GinStatsData::nDataPages, GinMetaPageData::nDataPages, GinStatsData::nEntries, GinMetaPageData::nEntries, GinStatsData::nEntryPages, GinMetaPageData::nEntryPages, ginxlogUpdateMeta::newRightlink, XLogRecData::next, ginxlogUpdateMeta::node, GinStatsData::nTotalPages, GinMetaPageData::nTotalPages, ginxlogUpdateMeta::ntuples, PageSetLSN, ginxlogUpdateMeta::prevTail, RelationData::rd_node, ReadBuffer(), RelationNeedsWAL, START_CRIT_SECTION, UnlockReleaseBuffer(), XLOG_GIN_UPDATE_META_PAGE, and XLogInsert().
Referenced by ginbuild(), and ginvacuumcleanup().
{ Buffer metabuffer; Page metapage; GinMetaPageData *metadata; metabuffer = ReadBuffer(index, GIN_METAPAGE_BLKNO); LockBuffer(metabuffer, GIN_EXCLUSIVE); metapage = BufferGetPage(metabuffer); metadata = GinPageGetMeta(metapage); START_CRIT_SECTION(); metadata->nTotalPages = stats->nTotalPages; metadata->nEntryPages = stats->nEntryPages; metadata->nDataPages = stats->nDataPages; metadata->nEntries = stats->nEntries; MarkBufferDirty(metabuffer); if (RelationNeedsWAL(index)) { XLogRecPtr recptr; ginxlogUpdateMeta data; XLogRecData rdata; data.node = index->rd_node; data.ntuples = 0; data.newRightlink = data.prevTail = InvalidBlockNumber; memcpy(&data.metadata, metadata, sizeof(GinMetaPageData)); rdata.buffer = InvalidBuffer; rdata.data = (char *) &data; rdata.len = sizeof(ginxlogUpdateMeta); rdata.next = NULL; recptr = XLogInsert(RM_GIN_ID, XLOG_GIN_UPDATE_META_PAGE, &rdata); PageSetLSN(metapage, recptr); } UnlockReleaseBuffer(metabuffer); END_CRIT_SECTION(); }
PGDLLIMPORT int GinFuzzySearchLimit |
Definition at line 127 of file globals.c.
Referenced by startScan().