From ce5326eed386959aac7a322880896ddeade7fd52 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Wed, 27 Nov 2013 15:43:05 +0200 Subject: More GIN refactoring. Separate the insertion payload from the more static portions of GinBtree. GinBtree now only contains information related to searching the tree, and the information of what to insert is passed separately. Add root block number to GinBtree, instead of passing it around all the functions as argument. Split off ginFinishSplit() from ginInsertValue(). ginFinishSplit is responsible for finding the parent and inserting the downlink to it. --- src/backend/access/gin/gininsert.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/backend/access/gin/gininsert.c') diff --git a/src/backend/access/gin/gininsert.c b/src/backend/access/gin/gininsert.c index 0a2883aae3d..556e31854ea 100644 --- a/src/backend/access/gin/gininsert.c +++ b/src/backend/access/gin/gininsert.c @@ -163,17 +163,20 @@ ginEntryInsert(GinState *ginstate, GinStatsData *buildStats) { GinBtreeData btree; + GinBtreeEntryInsertData insertdata; GinBtreeStack *stack; IndexTuple itup; Page page; + insertdata.isDelete = FALSE; + /* During index build, count the to-be-inserted entry */ if (buildStats) buildStats->nEntries++; ginPrepareEntryScan(&btree, attnum, key, category, ginstate); - stack = ginFindLeafPage(&btree, GIN_ROOT_BLKNO, false); + stack = ginFindLeafPage(&btree, false); page = BufferGetPage(stack->buffer); if (btree.findItem(&btree, stack)) @@ -201,7 +204,7 @@ ginEntryInsert(GinState *ginstate, itup = addItemPointersToLeafTuple(ginstate, itup, items, nitem, buildStats); - btree.isDelete = TRUE; + insertdata.isDelete = TRUE; } else { @@ -211,8 +214,8 @@ ginEntryInsert(GinState *ginstate, } /* Insert the new or modified leaf tuple */ - btree.entry = itup; - ginInsertValue(&btree, stack, buildStats); + insertdata.entry = itup; + ginInsertValue(&btree, stack, &insertdata, buildStats); pfree(itup); } -- cgit v1.2.3