Header And Logo

PostgreSQL
| The world's most advanced open source database.

Data Structures | Defines | Typedefs | Functions | Variables

gin.h File Reference

#include "access/xlog.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

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 Documentation

#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().

#define GINNProcs   5

Definition at line 26 of file gin.h.


Typedef Documentation

typedef struct GinStatsData GinStatsData

Function Documentation

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   ) 
void gin_xlog_startup ( void   ) 
void ginGetStats ( Relation  index,
GinStatsData stats 
)
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();
}


Variable Documentation

PGDLLIMPORT int GinFuzzySearchLimit

Definition at line 127 of file globals.c.

Referenced by startScan().