mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-06 15:24:56 +08:00
Fix a passel of inappropriately-named global functions in GIN.
The GIN code has absolutely no business exporting GIN-specific functions with names as generic as compareItemPointers() or newScanKey(); that's just trouble waiting to happen. I got annoyed about this again just now and decided to fix it. This commit ensures that all global symbols defined in access/gin/ have names including "gin" or "Gin". There were a couple of cases, like names involving "PostingItem", where arguably the names were already sufficiently nongeneric; but I figured as long as I was risking creating merge problems for unapplied GIN patches I might as well impose a uniform policy. I didn't touch any static symbol names. There might be some places where it'd be appropriate to rename some static functions to match siblings that are exported, but I'll leave that for another time.
This commit is contained in:
parent
48c7d9f6ff
commit
419d2374bf
@ -173,8 +173,8 @@ freeGinBtreeStack(GinBtreeStack *stack)
|
||||
* with vacuum process
|
||||
*/
|
||||
void
|
||||
findParents(GinBtree btree, GinBtreeStack *stack,
|
||||
BlockNumber rootBlkno)
|
||||
ginFindParents(GinBtree btree, GinBtreeStack *stack,
|
||||
BlockNumber rootBlkno)
|
||||
{
|
||||
|
||||
Page page;
|
||||
@ -456,7 +456,7 @@ ginInsertValue(GinBtree btree, GinBtreeStack *stack, GinStatsData *buildStats)
|
||||
* rightmost page, but we don't find parent, we should use
|
||||
* plain search...
|
||||
*/
|
||||
findParents(btree, stack, rootBlkno);
|
||||
ginFindParents(btree, stack, rootBlkno);
|
||||
parent = stack->parent;
|
||||
page = BufferGetPage(parent->buffer);
|
||||
break;
|
||||
|
@ -48,7 +48,7 @@ ginCombineData(RBNode *existing, const RBNode *newdata, void *arg)
|
||||
{
|
||||
int res;
|
||||
|
||||
res = compareItemPointers(eo->list + eo->number - 1, en->list);
|
||||
res = ginCompareItemPointers(eo->list + eo->number - 1, en->list);
|
||||
Assert(res != 0);
|
||||
|
||||
if (res > 0)
|
||||
@ -67,8 +67,8 @@ cmpEntryAccumulator(const RBNode *a, const RBNode *b, void *arg)
|
||||
const EntryAccumulator *eb = (const EntryAccumulator *) b;
|
||||
BuildAccumulator *accum = (BuildAccumulator *) arg;
|
||||
|
||||
return compareAttEntries(accum->ginstate, ea->attnum, ea->value,
|
||||
eb->attnum, eb->value);
|
||||
return ginCompareAttEntries(accum->ginstate, ea->attnum, ea->value,
|
||||
eb->attnum, eb->value);
|
||||
}
|
||||
|
||||
/* Allocator function for rbtree.c */
|
||||
@ -226,7 +226,7 @@ ginInsertRecordBA(BuildAccumulator *accum, ItemPointer heapptr, OffsetNumber att
|
||||
static int
|
||||
qsortCompareItemPointers(const void *a, const void *b)
|
||||
{
|
||||
int res = compareItemPointers((ItemPointer) a, (ItemPointer) b);
|
||||
int res = ginCompareItemPointers((ItemPointer) a, (ItemPointer) b);
|
||||
|
||||
Assert(res != 0);
|
||||
return res;
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include "utils/rel.h"
|
||||
|
||||
int
|
||||
compareItemPointers(ItemPointer a, ItemPointer b)
|
||||
ginCompareItemPointers(ItemPointer a, ItemPointer b)
|
||||
{
|
||||
if (GinItemPointerGetBlockNumber(a) == GinItemPointerGetBlockNumber(b))
|
||||
{
|
||||
@ -37,9 +37,9 @@ compareItemPointers(ItemPointer a, ItemPointer b)
|
||||
* Caller is responsible that there is enough space at *dst.
|
||||
*/
|
||||
uint32
|
||||
MergeItemPointers(ItemPointerData *dst,
|
||||
ItemPointerData *a, uint32 na,
|
||||
ItemPointerData *b, uint32 nb)
|
||||
ginMergeItemPointers(ItemPointerData *dst,
|
||||
ItemPointerData *a, uint32 na,
|
||||
ItemPointerData *b, uint32 nb)
|
||||
{
|
||||
ItemPointerData *dptr = dst;
|
||||
ItemPointerData *aptr = a,
|
||||
@ -47,7 +47,7 @@ MergeItemPointers(ItemPointerData *dst,
|
||||
|
||||
while (aptr - a < na && bptr - b < nb)
|
||||
{
|
||||
int cmp = compareItemPointers(aptr, bptr);
|
||||
int cmp = ginCompareItemPointers(aptr, bptr);
|
||||
|
||||
if (cmp > 0)
|
||||
*dptr++ = *bptr++;
|
||||
@ -82,7 +82,7 @@ dataIsMoveRight(GinBtree btree, Page page)
|
||||
if (GinPageRightMost(page))
|
||||
return FALSE;
|
||||
|
||||
return (compareItemPointers(btree->items + btree->curitem, iptr) > 0) ? TRUE : FALSE;
|
||||
return (ginCompareItemPointers(btree->items + btree->curitem, iptr) > 0) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -131,7 +131,7 @@ dataLocateItem(GinBtree btree, GinBtreeStack *stack)
|
||||
else
|
||||
{
|
||||
pitem = (PostingItem *) GinDataPageGetItem(page, mid);
|
||||
result = compareItemPointers(btree->items + btree->curitem, &(pitem->key));
|
||||
result = ginCompareItemPointers(btree->items + btree->curitem, &(pitem->key));
|
||||
}
|
||||
|
||||
if (result == 0)
|
||||
@ -189,7 +189,7 @@ dataLocateLeafItem(GinBtree btree, GinBtreeStack *stack)
|
||||
{
|
||||
OffsetNumber mid = low + ((high - low) / 2);
|
||||
|
||||
result = compareItemPointers(btree->items + btree->curitem, (ItemPointer) GinDataPageGetItem(page, mid));
|
||||
result = ginCompareItemPointers(btree->items + btree->curitem, (ItemPointer) GinDataPageGetItem(page, mid));
|
||||
|
||||
if (result == 0)
|
||||
{
|
||||
@ -297,7 +297,7 @@ GinDataPageAddItem(Page page, void *data, OffsetNumber offset)
|
||||
* Deletes posting item from non-leaf page
|
||||
*/
|
||||
void
|
||||
PageDeletePostingItem(Page page, OffsetNumber offset)
|
||||
GinPageDeletePostingItem(Page page, OffsetNumber offset)
|
||||
{
|
||||
OffsetNumber maxoff = GinPageGetOpaque(page)->maxoff;
|
||||
|
||||
@ -571,7 +571,7 @@ dataSplitPage(GinBtree btree, Buffer lbuf, Buffer rbuf, OffsetNumber off, XLogRe
|
||||
* Also called from ginxlog, should not use btree
|
||||
*/
|
||||
void
|
||||
dataFillRoot(GinBtree btree, Buffer root, Buffer lbuf, Buffer rbuf)
|
||||
ginDataFillRoot(GinBtree btree, Buffer root, Buffer lbuf, Buffer rbuf)
|
||||
{
|
||||
Page page = BufferGetPage(root),
|
||||
lpage = BufferGetPage(lbuf),
|
||||
@ -589,7 +589,7 @@ dataFillRoot(GinBtree btree, Buffer root, Buffer lbuf, Buffer rbuf)
|
||||
}
|
||||
|
||||
void
|
||||
prepareDataScan(GinBtree btree, Relation index)
|
||||
ginPrepareDataScan(GinBtree btree, Relation index)
|
||||
{
|
||||
memset(btree, 0, sizeof(GinBtreeData));
|
||||
|
||||
@ -603,7 +603,7 @@ prepareDataScan(GinBtree btree, Relation index)
|
||||
btree->isEnoughSpace = dataIsEnoughSpace;
|
||||
btree->placeToPage = dataPlaceToPage;
|
||||
btree->splitPage = dataSplitPage;
|
||||
btree->fillRoot = dataFillRoot;
|
||||
btree->fillRoot = ginDataFillRoot;
|
||||
|
||||
btree->isData = TRUE;
|
||||
btree->searchMode = FALSE;
|
||||
@ -613,11 +613,11 @@ prepareDataScan(GinBtree btree, Relation index)
|
||||
}
|
||||
|
||||
GinPostingTreeScan *
|
||||
prepareScanPostingTree(Relation index, BlockNumber rootBlkno, bool searchMode)
|
||||
ginPrepareScanPostingTree(Relation index, BlockNumber rootBlkno, bool searchMode)
|
||||
{
|
||||
GinPostingTreeScan *gdi = (GinPostingTreeScan *) palloc0(sizeof(GinPostingTreeScan));
|
||||
|
||||
prepareDataScan(&gdi->btree, index);
|
||||
ginPrepareDataScan(&gdi->btree, index);
|
||||
|
||||
gdi->btree.searchMode = searchMode;
|
||||
gdi->btree.fullScan = searchMode;
|
||||
@ -665,7 +665,7 @@ ginInsertItemPointer(GinPostingTreeScan *gdi,
|
||||
}
|
||||
|
||||
Buffer
|
||||
scanBeginPostingTree(GinPostingTreeScan *gdi)
|
||||
ginScanBeginPostingTree(GinPostingTreeScan *gdi)
|
||||
{
|
||||
gdi->stack = ginFindLeafPage(&gdi->btree, gdi->stack);
|
||||
return gdi->stack->buffer;
|
||||
|
@ -172,10 +172,10 @@ entryIsMoveRight(GinBtree btree, Page page)
|
||||
|
||||
itup = getRightMostTuple(page);
|
||||
|
||||
if (compareAttEntries(btree->ginstate,
|
||||
btree->entryAttnum, btree->entryValue,
|
||||
gintuple_get_attrnum(btree->ginstate, itup),
|
||||
gin_index_getattr(btree->ginstate, itup)) > 0)
|
||||
if (ginCompareAttEntries(btree->ginstate,
|
||||
btree->entryAttnum, btree->entryValue,
|
||||
gintuple_get_attrnum(btree->ginstate, itup),
|
||||
gin_index_getattr(btree->ginstate, itup)) > 0)
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
@ -221,8 +221,9 @@ entryLocateEntry(GinBtree btree, GinBtreeStack *stack)
|
||||
else
|
||||
{
|
||||
itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, mid));
|
||||
result = compareAttEntries(btree->ginstate,
|
||||
btree->entryAttnum, btree->entryValue,
|
||||
result = ginCompareAttEntries(btree->ginstate,
|
||||
btree->entryAttnum,
|
||||
btree->entryValue,
|
||||
gintuple_get_attrnum(btree->ginstate, itup),
|
||||
gin_index_getattr(btree->ginstate, itup));
|
||||
}
|
||||
@ -286,8 +287,9 @@ entryLocateLeafEntry(GinBtree btree, GinBtreeStack *stack)
|
||||
int result;
|
||||
|
||||
itup = (IndexTuple) PageGetItem(page, PageGetItemId(page, mid));
|
||||
result = compareAttEntries(btree->ginstate,
|
||||
btree->entryAttnum, btree->entryValue,
|
||||
result = ginCompareAttEntries(btree->ginstate,
|
||||
btree->entryAttnum,
|
||||
btree->entryValue,
|
||||
gintuple_get_attrnum(btree->ginstate, itup),
|
||||
gin_index_getattr(btree->ginstate, itup));
|
||||
if (result == 0)
|
||||
@ -636,7 +638,7 @@ ginPageGetLinkItup(Buffer buf)
|
||||
* Also called from ginxlog, should not use btree
|
||||
*/
|
||||
void
|
||||
entryFillRoot(GinBtree btree, Buffer root, Buffer lbuf, Buffer rbuf)
|
||||
ginEntryFillRoot(GinBtree btree, Buffer root, Buffer lbuf, Buffer rbuf)
|
||||
{
|
||||
Page page;
|
||||
IndexTuple itup;
|
||||
@ -655,7 +657,7 @@ entryFillRoot(GinBtree btree, Buffer root, Buffer lbuf, Buffer rbuf)
|
||||
}
|
||||
|
||||
void
|
||||
prepareEntryScan(GinBtree btree, Relation index, OffsetNumber attnum, Datum value, GinState *ginstate)
|
||||
ginPrepareEntryScan(GinBtree btree, Relation index, OffsetNumber attnum, Datum value, GinState *ginstate)
|
||||
{
|
||||
memset(btree, 0, sizeof(GinBtreeData));
|
||||
|
||||
@ -670,7 +672,7 @@ prepareEntryScan(GinBtree btree, Relation index, OffsetNumber attnum, Datum valu
|
||||
btree->isEnoughSpace = entryIsEnoughSpace;
|
||||
btree->placeToPage = entryPlaceToPage;
|
||||
btree->splitPage = entrySplitPage;
|
||||
btree->fillRoot = entryFillRoot;
|
||||
btree->fillRoot = ginEntryFillRoot;
|
||||
|
||||
btree->isData = FALSE;
|
||||
btree->searchMode = FALSE;
|
||||
|
@ -437,7 +437,7 @@ ginHeapTupleFastCollect(Relation index, GinState *ginstate,
|
||||
int32 i,
|
||||
nentries;
|
||||
|
||||
entries = extractEntriesSU(ginstate, attnum, value, &nentries);
|
||||
entries = ginExtractEntriesSU(ginstate, attnum, value, &nentries);
|
||||
|
||||
if (nentries == 0)
|
||||
/* nothing to insert */
|
||||
|
@ -51,7 +51,7 @@ findItemInPage(Page page, ItemPointer item, OffsetNumber *off)
|
||||
*/
|
||||
for (*off = FirstOffsetNumber; *off <= maxoff; (*off)++)
|
||||
{
|
||||
res = compareItemPointers(item, (ItemPointer) GinDataPageGetItem(page, *off));
|
||||
res = ginCompareItemPointers(item, (ItemPointer) GinDataPageGetItem(page, *off));
|
||||
|
||||
if (res <= 0)
|
||||
return true;
|
||||
@ -99,9 +99,9 @@ scanForItems(Relation index, GinScanEntry scanEntry, BlockNumber rootPostingTree
|
||||
Page page;
|
||||
BlockNumber blkno;
|
||||
|
||||
gdi = prepareScanPostingTree(index, rootPostingTree, TRUE);
|
||||
gdi = ginPrepareScanPostingTree(index, rootPostingTree, TRUE);
|
||||
|
||||
buffer = scanBeginPostingTree(gdi);
|
||||
buffer = ginScanBeginPostingTree(gdi);
|
||||
IncrBufferRefCount(buffer); /* prevent unpin in freeGinBtreeStack */
|
||||
|
||||
freeGinBtreeStack(gdi->stack);
|
||||
@ -241,7 +241,8 @@ computePartialMatchList(GinBtreeData *btree, GinBtreeStack *stack, GinScanEntry
|
||||
if (gintuple_get_attrnum(btree->ginstate, itup) != scanEntry->attnum)
|
||||
elog(ERROR, "lost saved point in index"); /* must not happen !!! */
|
||||
|
||||
if (compareEntries(btree->ginstate, scanEntry->attnum, newDatum, savedDatum) == 0)
|
||||
if (ginCompareEntries(btree->ginstate, scanEntry->attnum,
|
||||
newDatum, savedDatum) == 0)
|
||||
{
|
||||
/* Found! */
|
||||
if (btree->ginstate->origTupdesc->attrs[scanEntry->attnum - 1]->attbyval == false)
|
||||
@ -298,7 +299,7 @@ startScanEntry(Relation index, GinState *ginstate, GinScanEntry entry)
|
||||
* posting list in memory
|
||||
*/
|
||||
|
||||
prepareEntryScan(&btreeEntry, index, entry->attnum, entry->entry, ginstate);
|
||||
ginPrepareEntryScan(&btreeEntry, index, entry->attnum, entry->entry, ginstate);
|
||||
btreeEntry.searchMode = TRUE;
|
||||
stackEntry = ginFindLeafPage(&btreeEntry, NULL);
|
||||
page = BufferGetPage(stackEntry->buffer);
|
||||
@ -359,9 +360,9 @@ startScanEntry(Relation index, GinState *ginstate, GinScanEntry entry)
|
||||
*/
|
||||
LockBuffer(stackEntry->buffer, GIN_UNLOCK);
|
||||
needUnlock = FALSE;
|
||||
gdi = prepareScanPostingTree(index, rootPostingTree, TRUE);
|
||||
gdi = ginPrepareScanPostingTree(index, rootPostingTree, TRUE);
|
||||
|
||||
entry->buffer = scanBeginPostingTree(gdi);
|
||||
entry->buffer = ginScanBeginPostingTree(gdi);
|
||||
|
||||
/*
|
||||
* We keep buffer pinned because we need to prevent deletion of
|
||||
@ -504,8 +505,8 @@ entryGetNextItem(Relation index, GinScanEntry entry)
|
||||
LockBuffer(entry->buffer, GIN_UNLOCK);
|
||||
|
||||
if (!ItemPointerIsValid(&entry->curItem) ||
|
||||
compareItemPointers(&entry->curItem,
|
||||
entry->list + entry->offset - 1) == 0)
|
||||
ginCompareItemPointers(&entry->curItem,
|
||||
entry->list + entry->offset - 1) == 0)
|
||||
{
|
||||
/*
|
||||
* First pages are deleted or empty, or we found exact
|
||||
@ -699,11 +700,11 @@ keyGetItem(Relation index, GinState *ginstate, MemoryContext tempCtx,
|
||||
entry = key->scanEntry + i;
|
||||
|
||||
while (entry->isFinished == FALSE &&
|
||||
compareItemPointers(&entry->curItem, &myAdvancePast) <= 0)
|
||||
ginCompareItemPointers(&entry->curItem, &myAdvancePast) <= 0)
|
||||
entryGetItem(index, entry);
|
||||
|
||||
if (entry->isFinished == FALSE &&
|
||||
compareItemPointers(&entry->curItem, &key->curItem) < 0)
|
||||
ginCompareItemPointers(&entry->curItem, &key->curItem) < 0)
|
||||
key->curItem = entry->curItem;
|
||||
}
|
||||
|
||||
@ -757,7 +758,7 @@ keyGetItem(Relation index, GinState *ginstate, MemoryContext tempCtx,
|
||||
{
|
||||
entry = key->scanEntry + i;
|
||||
if (entry->isFinished == FALSE &&
|
||||
compareItemPointers(&entry->curItem, &curPageLossy) == 0)
|
||||
ginCompareItemPointers(&entry->curItem, &curPageLossy) == 0)
|
||||
{
|
||||
if (haveLossyEntry)
|
||||
{
|
||||
@ -810,7 +811,7 @@ keyGetItem(Relation index, GinState *ginstate, MemoryContext tempCtx,
|
||||
{
|
||||
entry = key->scanEntry + i;
|
||||
if (entry->isFinished == FALSE &&
|
||||
compareItemPointers(&entry->curItem, &key->curItem) == 0)
|
||||
ginCompareItemPointers(&entry->curItem, &key->curItem) == 0)
|
||||
key->entryRes[i] = TRUE;
|
||||
else
|
||||
key->entryRes[i] = FALSE;
|
||||
@ -1071,10 +1072,10 @@ collectDatumForItem(IndexScanDesc scan, pendingPosition *pos)
|
||||
datum[StopMiddle - 1] = gin_index_getattr(&so->ginstate, itup);
|
||||
datumExtracted[StopMiddle - 1] = true;
|
||||
}
|
||||
res = compareEntries(&so->ginstate,
|
||||
entry->attnum,
|
||||
entry->entry,
|
||||
datum[StopMiddle - 1]);
|
||||
res = ginCompareEntries(&so->ginstate,
|
||||
entry->attnum,
|
||||
entry->entry,
|
||||
datum[StopMiddle - 1]);
|
||||
|
||||
if (res == 0)
|
||||
{
|
||||
@ -1282,14 +1283,14 @@ scanGetItem(IndexScanDesc scan, ItemPointer advancePast,
|
||||
GinScanKey key = so->keys + i;
|
||||
|
||||
while (key->isFinished == FALSE &&
|
||||
compareItemPointers(&key->curItem, &myAdvancePast) <= 0)
|
||||
ginCompareItemPointers(&key->curItem, &myAdvancePast) <= 0)
|
||||
keyGetItem(scan->indexRelation, &so->ginstate, so->tempCtx,
|
||||
key, &myAdvancePast);
|
||||
|
||||
if (key->isFinished)
|
||||
return FALSE; /* finished one of keys */
|
||||
|
||||
if (compareItemPointers(&key->curItem, item) < 0)
|
||||
if (ginCompareItemPointers(&key->curItem, item) < 0)
|
||||
*item = key->curItem;
|
||||
}
|
||||
|
||||
@ -1321,7 +1322,7 @@ scanGetItem(IndexScanDesc scan, ItemPointer advancePast,
|
||||
{
|
||||
GinScanKey key = so->keys + i;
|
||||
|
||||
if (compareItemPointers(item, &key->curItem) == 0)
|
||||
if (ginCompareItemPointers(item, &key->curItem) == 0)
|
||||
continue;
|
||||
if (ItemPointerIsLossyPage(&key->curItem) &&
|
||||
GinItemPointerGetBlockNumber(&key->curItem) ==
|
||||
@ -1372,7 +1373,7 @@ gingetbitmap(PG_FUNCTION_ARGS)
|
||||
bool recheck;
|
||||
|
||||
if (GinIsNewKey(scan))
|
||||
newScanKey(scan);
|
||||
ginNewScanKey(scan);
|
||||
|
||||
if (GinIsVoidRes(scan))
|
||||
PG_RETURN_INT64(0);
|
||||
|
@ -114,9 +114,10 @@ addItemPointersToTuple(Relation index, GinState *ginstate,
|
||||
/* good, small enough */
|
||||
uint32 newnitem;
|
||||
|
||||
newnitem = MergeItemPointers(GinGetPosting(res),
|
||||
GinGetPosting(old), GinGetNPosting(old),
|
||||
items, nitem);
|
||||
newnitem = ginMergeItemPointers(GinGetPosting(res),
|
||||
GinGetPosting(old),
|
||||
GinGetNPosting(old),
|
||||
items, nitem);
|
||||
/* merge might have eliminated some duplicate items */
|
||||
GinShortenTuple(res, newnitem);
|
||||
}
|
||||
@ -130,7 +131,7 @@ addItemPointersToTuple(Relation index, GinState *ginstate,
|
||||
postingRoot = createPostingTree(index, GinGetPosting(old), GinGetNPosting(old));
|
||||
GinSetPostingTree(res, postingRoot);
|
||||
|
||||
gdi = prepareScanPostingTree(index, postingRoot, FALSE);
|
||||
gdi = ginPrepareScanPostingTree(index, postingRoot, FALSE);
|
||||
gdi->btree.isBuild = (buildStats != NULL);
|
||||
|
||||
ginInsertItemPointer(gdi, items, nitem, buildStats);
|
||||
@ -166,7 +167,7 @@ ginEntryInsert(Relation index, GinState *ginstate,
|
||||
if (buildStats)
|
||||
buildStats->nEntries++;
|
||||
|
||||
prepareEntryScan(&btree, index, attnum, value, ginstate);
|
||||
ginPrepareEntryScan(&btree, index, attnum, value, ginstate);
|
||||
|
||||
stack = ginFindLeafPage(&btree, NULL);
|
||||
page = BufferGetPage(stack->buffer);
|
||||
@ -187,7 +188,7 @@ ginEntryInsert(Relation index, GinState *ginstate,
|
||||
freeGinBtreeStack(stack);
|
||||
|
||||
/* insert into posting tree */
|
||||
gdi = prepareScanPostingTree(index, rootPostingTree, FALSE);
|
||||
gdi = ginPrepareScanPostingTree(index, rootPostingTree, FALSE);
|
||||
gdi->btree.isBuild = (buildStats != NULL);
|
||||
ginInsertItemPointer(gdi, items, nitem, buildStats);
|
||||
pfree(gdi);
|
||||
@ -233,7 +234,7 @@ ginHeapTupleBulkInsert(GinBuildState *buildstate, OffsetNumber attnum, Datum val
|
||||
MemoryContext oldCtx;
|
||||
|
||||
oldCtx = MemoryContextSwitchTo(buildstate->funcCtx);
|
||||
entries = extractEntriesSU(buildstate->accum.ginstate, attnum, value, &nentries);
|
||||
entries = ginExtractEntriesSU(buildstate->accum.ginstate, attnum, value, &nentries);
|
||||
MemoryContextSwitchTo(oldCtx);
|
||||
|
||||
if (nentries == 0)
|
||||
@ -420,7 +421,7 @@ ginHeapTupleInsert(Relation index, GinState *ginstate, OffsetNumber attnum, Datu
|
||||
int32 i,
|
||||
nentries;
|
||||
|
||||
entries = extractEntriesSU(ginstate, attnum, value, &nentries);
|
||||
entries = ginExtractEntriesSU(ginstate, attnum, value, &nentries);
|
||||
|
||||
if (nentries == 0)
|
||||
/* nothing to insert */
|
||||
|
@ -75,7 +75,8 @@ fillScanKey(GinState *ginstate, GinScanKey key, OffsetNumber attnum, Datum query
|
||||
/* link to the equals entry in current scan key */
|
||||
key->scanEntry[i].master = NULL;
|
||||
for (j = 0; j < i; j++)
|
||||
if (compareEntries(ginstate, attnum, entryValues[i], entryValues[j]) == 0 &&
|
||||
if (ginCompareEntries(ginstate, attnum,
|
||||
entryValues[i], entryValues[j]) == 0 &&
|
||||
key->scanEntry[i].isPartialMatch == key->scanEntry[j].isPartialMatch &&
|
||||
key->scanEntry[i].strategy == key->scanEntry[j].strategy)
|
||||
{
|
||||
@ -155,7 +156,7 @@ freeScanKeys(GinScanKey keys, uint32 nkeys)
|
||||
}
|
||||
|
||||
void
|
||||
newScanKey(IndexScanDesc scan)
|
||||
ginNewScanKey(IndexScanDesc scan)
|
||||
{
|
||||
ScanKey scankey = scan->keyData;
|
||||
GinScanOpaque so = (GinScanOpaque) scan->opaque;
|
||||
|
@ -236,22 +236,18 @@ GinInitMetabuffer(Buffer b)
|
||||
}
|
||||
|
||||
int
|
||||
compareEntries(GinState *ginstate, OffsetNumber attnum, Datum a, Datum b)
|
||||
ginCompareEntries(GinState *ginstate, OffsetNumber attnum, Datum a, Datum b)
|
||||
{
|
||||
return DatumGetInt32(
|
||||
FunctionCall2(
|
||||
&ginstate->compareFn[attnum - 1],
|
||||
a, b
|
||||
)
|
||||
);
|
||||
return DatumGetInt32(FunctionCall2(&ginstate->compareFn[attnum - 1],
|
||||
a, b));
|
||||
}
|
||||
|
||||
int
|
||||
compareAttEntries(GinState *ginstate, OffsetNumber attnum_a, Datum a,
|
||||
OffsetNumber attnum_b, Datum b)
|
||||
ginCompareAttEntries(GinState *ginstate, OffsetNumber attnum_a, Datum a,
|
||||
OffsetNumber attnum_b, Datum b)
|
||||
{
|
||||
if (attnum_a == attnum_b)
|
||||
return compareEntries(ginstate, attnum_a, a, b);
|
||||
return ginCompareEntries(ginstate, attnum_a, a, b);
|
||||
|
||||
return (attnum_a < attnum_b) ? -1 : 1;
|
||||
}
|
||||
@ -275,7 +271,7 @@ cmpEntries(const Datum *a, const Datum *b, cmpEntriesData *arg)
|
||||
}
|
||||
|
||||
Datum *
|
||||
extractEntriesS(GinState *ginstate, OffsetNumber attnum, Datum value, int32 *nentries,
|
||||
ginExtractEntriesS(GinState *ginstate, OffsetNumber attnum, Datum value, int32 *nentries,
|
||||
bool *needUnique)
|
||||
{
|
||||
Datum *entries;
|
||||
@ -305,11 +301,11 @@ extractEntriesS(GinState *ginstate, OffsetNumber attnum, Datum value, int32 *nen
|
||||
|
||||
|
||||
Datum *
|
||||
extractEntriesSU(GinState *ginstate, OffsetNumber attnum, Datum value, int32 *nentries)
|
||||
ginExtractEntriesSU(GinState *ginstate, OffsetNumber attnum, Datum value, int32 *nentries)
|
||||
{
|
||||
bool needUnique;
|
||||
Datum *entries = extractEntriesS(ginstate, attnum, value, nentries,
|
||||
&needUnique);
|
||||
Datum *entries = ginExtractEntriesS(ginstate, attnum, value, nentries,
|
||||
&needUnique);
|
||||
|
||||
if (needUnique)
|
||||
{
|
||||
@ -320,7 +316,7 @@ extractEntriesSU(GinState *ginstate, OffsetNumber attnum, Datum value, int32 *ne
|
||||
|
||||
while (ptr - entries < *nentries)
|
||||
{
|
||||
if (compareEntries(ginstate, attnum, *ptr, *res) != 0)
|
||||
if (ginCompareEntries(ginstate, attnum, *ptr, *res) != 0)
|
||||
*(++res) = *ptr++;
|
||||
else
|
||||
ptr++;
|
||||
|
@ -293,7 +293,7 @@ ginDeletePage(GinVacuumState *gvs, BlockNumber deleteBlkno, BlockNumber leftBlkn
|
||||
Assert(PostingItemGetBlockNumber(tod) == deleteBlkno);
|
||||
} while (0);
|
||||
#endif
|
||||
PageDeletePostingItem(parentPage, myoff);
|
||||
GinPageDeletePostingItem(parentPage, myoff);
|
||||
|
||||
page = BufferGetPage(dBuffer);
|
||||
|
||||
|
@ -339,12 +339,12 @@ ginRedoSplit(XLogRecPtr lsn, XLogRecord *record)
|
||||
if (data->isData)
|
||||
{
|
||||
Assert(data->rootBlkno != GIN_ROOT_BLKNO);
|
||||
dataFillRoot(NULL, rootBuf, lbuffer, rbuffer);
|
||||
ginDataFillRoot(NULL, rootBuf, lbuffer, rbuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert(data->rootBlkno == GIN_ROOT_BLKNO);
|
||||
entryFillRoot(NULL, rootBuf, lbuffer, rbuffer);
|
||||
ginEntryFillRoot(NULL, rootBuf, lbuffer, rbuffer);
|
||||
}
|
||||
|
||||
PageSetLSN(rootPage, lsn);
|
||||
@ -448,7 +448,7 @@ ginRedoDeletePage(XLogRecPtr lsn, XLogRecord *record)
|
||||
{
|
||||
Assert(GinPageIsData(page));
|
||||
Assert(!GinPageIsLeaf(page));
|
||||
PageDeletePostingItem(page, data->parentOffset);
|
||||
GinPageDeletePostingItem(page, data->parentOffset);
|
||||
PageSetLSN(page, lsn);
|
||||
PageSetTLI(page, ThisTimeLineID);
|
||||
MarkBufferDirty(buffer);
|
||||
@ -813,14 +813,14 @@ ginContinueSplit(ginIncompleteSplit *split)
|
||||
|
||||
if (split->rootBlkno == GIN_ROOT_BLKNO)
|
||||
{
|
||||
prepareEntryScan(&btree, reln, InvalidOffsetNumber, (Datum) 0, NULL);
|
||||
ginPrepareEntryScan(&btree, reln, InvalidOffsetNumber, (Datum) 0, NULL);
|
||||
btree.entry = ginPageGetLinkItup(buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
Page page = BufferGetPage(buffer);
|
||||
|
||||
prepareDataScan(&btree, reln);
|
||||
ginPrepareDataScan(&btree, reln);
|
||||
|
||||
PostingItemSetBlockNumber(&(btree.pitem), split->leftBlkno);
|
||||
if (GinPageIsLeaf(page))
|
||||
@ -838,7 +838,7 @@ ginContinueSplit(ginIncompleteSplit *split)
|
||||
stack.off = InvalidOffsetNumber;
|
||||
stack.parent = NULL;
|
||||
|
||||
findParents(&btree, &stack, split->rootBlkno);
|
||||
ginFindParents(&btree, &stack, split->rootBlkno);
|
||||
ginInsertValue(&btree, stack.parent, NULL);
|
||||
|
||||
FreeFakeRelcacheEntry(reln);
|
||||
|
@ -362,12 +362,12 @@ extern Buffer GinNewBuffer(Relation index);
|
||||
extern void GinInitBuffer(Buffer b, uint32 f);
|
||||
extern void GinInitPage(Page page, uint32 f, Size pageSize);
|
||||
extern void GinInitMetabuffer(Buffer b);
|
||||
extern int compareEntries(GinState *ginstate, OffsetNumber attnum, Datum a, Datum b);
|
||||
extern int compareAttEntries(GinState *ginstate, OffsetNumber attnum_a, Datum a,
|
||||
extern int ginCompareEntries(GinState *ginstate, OffsetNumber attnum, Datum a, Datum b);
|
||||
extern int ginCompareAttEntries(GinState *ginstate, OffsetNumber attnum_a, Datum a,
|
||||
OffsetNumber attnum_b, Datum b);
|
||||
extern Datum *extractEntriesS(GinState *ginstate, OffsetNumber attnum, Datum value,
|
||||
extern Datum *ginExtractEntriesS(GinState *ginstate, OffsetNumber attnum, Datum value,
|
||||
int32 *nentries, bool *needUnique);
|
||||
extern Datum *extractEntriesSU(GinState *ginstate, OffsetNumber attnum, Datum value, int32 *nentries);
|
||||
extern Datum *ginExtractEntriesSU(GinState *ginstate, OffsetNumber attnum, Datum value, int32 *nentries);
|
||||
|
||||
extern Datum gin_index_getattr(GinState *ginstate, IndexTuple tuple);
|
||||
extern OffsetNumber gintuple_get_attrnum(GinState *ginstate, IndexTuple tuple);
|
||||
@ -460,26 +460,26 @@ extern GinBtreeStack *ginFindLeafPage(GinBtree btree, GinBtreeStack *stack);
|
||||
extern void freeGinBtreeStack(GinBtreeStack *stack);
|
||||
extern void ginInsertValue(GinBtree btree, GinBtreeStack *stack,
|
||||
GinStatsData *buildStats);
|
||||
extern void findParents(GinBtree btree, GinBtreeStack *stack, BlockNumber rootBlkno);
|
||||
extern void ginFindParents(GinBtree btree, GinBtreeStack *stack, BlockNumber rootBlkno);
|
||||
|
||||
/* ginentrypage.c */
|
||||
extern IndexTuple GinFormTuple(Relation index, GinState *ginstate,
|
||||
OffsetNumber attnum, Datum key,
|
||||
ItemPointerData *ipd, uint32 nipd, bool errorTooBig);
|
||||
extern void GinShortenTuple(IndexTuple itup, uint32 nipd);
|
||||
extern void prepareEntryScan(GinBtree btree, Relation index, OffsetNumber attnum,
|
||||
extern void ginPrepareEntryScan(GinBtree btree, Relation index, OffsetNumber attnum,
|
||||
Datum value, GinState *ginstate);
|
||||
extern void entryFillRoot(GinBtree btree, Buffer root, Buffer lbuf, Buffer rbuf);
|
||||
extern void ginEntryFillRoot(GinBtree btree, Buffer root, Buffer lbuf, Buffer rbuf);
|
||||
extern IndexTuple ginPageGetLinkItup(Buffer buf);
|
||||
|
||||
/* gindatapage.c */
|
||||
extern int compareItemPointers(ItemPointer a, ItemPointer b);
|
||||
extern uint32 MergeItemPointers(ItemPointerData *dst,
|
||||
extern int ginCompareItemPointers(ItemPointer a, ItemPointer b);
|
||||
extern uint32 ginMergeItemPointers(ItemPointerData *dst,
|
||||
ItemPointerData *a, uint32 na,
|
||||
ItemPointerData *b, uint32 nb);
|
||||
|
||||
extern void GinDataPageAddItem(Page page, void *data, OffsetNumber offset);
|
||||
extern void PageDeletePostingItem(Page page, OffsetNumber offset);
|
||||
extern void GinPageDeletePostingItem(Page page, OffsetNumber offset);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@ -487,14 +487,14 @@ typedef struct
|
||||
GinBtreeStack *stack;
|
||||
} GinPostingTreeScan;
|
||||
|
||||
extern GinPostingTreeScan *prepareScanPostingTree(Relation index,
|
||||
extern GinPostingTreeScan *ginPrepareScanPostingTree(Relation index,
|
||||
BlockNumber rootBlkno, bool searchMode);
|
||||
extern void ginInsertItemPointer(GinPostingTreeScan *gdi,
|
||||
ItemPointerData *items, uint32 nitem,
|
||||
GinStatsData *buildStats);
|
||||
extern Buffer scanBeginPostingTree(GinPostingTreeScan *gdi);
|
||||
extern void dataFillRoot(GinBtree btree, Buffer root, Buffer lbuf, Buffer rbuf);
|
||||
extern void prepareDataScan(GinBtree btree, Relation index);
|
||||
extern Buffer ginScanBeginPostingTree(GinPostingTreeScan *gdi);
|
||||
extern void ginDataFillRoot(GinBtree btree, Buffer root, Buffer lbuf, Buffer rbuf);
|
||||
extern void ginPrepareDataScan(GinBtree btree, Relation index);
|
||||
|
||||
/* ginscan.c */
|
||||
|
||||
@ -583,7 +583,7 @@ extern Datum ginendscan(PG_FUNCTION_ARGS);
|
||||
extern Datum ginrescan(PG_FUNCTION_ARGS);
|
||||
extern Datum ginmarkpos(PG_FUNCTION_ARGS);
|
||||
extern Datum ginrestrpos(PG_FUNCTION_ARGS);
|
||||
extern void newScanKey(IndexScanDesc scan);
|
||||
extern void ginNewScanKey(IndexScanDesc scan);
|
||||
|
||||
/* ginget.c */
|
||||
extern PGDLLIMPORT int GinFuzzySearchLimit;
|
||||
|
Loading…
Reference in New Issue
Block a user