mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Misc GIN refactoring.
Merge the isEnoughSpace and placeToPage functions in the b-tree interface into one function that tries to put a tuple on page, and returns false if it doesn't fit. Move createPostingTree function to gindatapage.c, and change its contract so that it can be passed more items than fit on the root page. It's in a better position than the callers to know how many items fit. Move ginMergeItemPointers out of gindatapage.c, into a separate file. These changes make no difference now, but reduce the footprint of Alexander Korotkov's upcoming patch to pack item pointers more tightly.
This commit is contained in:
@ -486,9 +486,12 @@ entryPreparePage(GinBtree btree, Page page, OffsetNumber off)
|
||||
|
||||
/*
|
||||
* Place tuple on page and fills WAL record
|
||||
*
|
||||
* If the tuple doesn't fit, returns false without modifying the page.
|
||||
*/
|
||||
static void
|
||||
entryPlaceToPage(GinBtree btree, Buffer buf, OffsetNumber off, XLogRecData **prdata)
|
||||
static bool
|
||||
entryPlaceToPage(GinBtree btree, Buffer buf, OffsetNumber off,
|
||||
XLogRecData **prdata)
|
||||
{
|
||||
Page page = BufferGetPage(buf);
|
||||
OffsetNumber placed;
|
||||
@ -498,6 +501,10 @@ entryPlaceToPage(GinBtree btree, Buffer buf, OffsetNumber off, XLogRecData **prd
|
||||
static XLogRecData rdata[3];
|
||||
static ginxlogInsert data;
|
||||
|
||||
/* quick exit if it doesn't fit */
|
||||
if (!entryIsEnoughSpace(btree, buf, off))
|
||||
return false;
|
||||
|
||||
*prdata = rdata;
|
||||
data.updateBlkno = entryPreparePage(btree, page, off);
|
||||
|
||||
@ -543,6 +550,8 @@ entryPlaceToPage(GinBtree btree, Buffer buf, OffsetNumber off, XLogRecData **prd
|
||||
rdata[cnt].next = NULL;
|
||||
|
||||
btree->entry = NULL;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -724,7 +733,6 @@ ginPrepareEntryScan(GinBtree btree, OffsetNumber attnum,
|
||||
btree->findItem = entryLocateLeafEntry;
|
||||
btree->findChildPtr = entryFindChildPtr;
|
||||
btree->getLeftMostPage = entryGetLeftMostPage;
|
||||
btree->isEnoughSpace = entryIsEnoughSpace;
|
||||
btree->placeToPage = entryPlaceToPage;
|
||||
btree->splitPage = entrySplitPage;
|
||||
btree->fillRoot = ginEntryFillRoot;
|
||||
|
Reference in New Issue
Block a user