BlockNumber blkno;
Buffer buffer;
Page page;
- int itemsCount;
+ int nrootitems;
/* Calculate how many TIDs will fit on first page. */
- itemsCount = Min(nitems, GinMaxLeafDataItems);
+ nrootitems = Min(nitems, GinMaxLeafDataItems);
/*
* Create the root page.
START_CRIT_SECTION();
GinInitBuffer(buffer, GIN_DATA | GIN_LEAF);
- memcpy(GinDataPageGetData(page), items, sizeof(ItemPointerData) * nitems);
- GinPageGetOpaque(page)->maxoff = nitems;
+ memcpy(GinDataPageGetData(page), items, sizeof(ItemPointerData) * nrootitems);
+ GinPageGetOpaque(page)->maxoff = nrootitems;
MarkBufferDirty(buffer);
data.node = index->rd_node;
data.blkno = blkno;
- data.nitem = nitems;
+ data.nitem = nrootitems;
rdata[0].buffer = InvalidBuffer;
rdata[0].data = (char *) &data;
rdata[1].buffer = InvalidBuffer;
rdata[1].data = (char *) items;
- rdata[1].len = sizeof(ItemPointerData) * itemsCount;
+ rdata[1].len = sizeof(ItemPointerData) * nrootitems;
rdata[1].next = NULL;
recptr = XLogInsert(RM_GIN_ID, XLOG_GIN_CREATE_PTREE, rdata);
/*
* Add any remaining TIDs to the newly-created posting tree.
*/
- if (itemsCount < nitems)
+ if (nitems > nrootitems)
{
GinPostingTreeScan *gdi;
gdi->btree.isBuild = (buildStats != NULL);
ginInsertItemPointers(gdi,
- items + itemsCount,
- nitems - itemsCount,
+ items + nrootitems,
+ nitems - nrootitems,
buildStats);
pfree(gdi);