* If 'searchmode' is false, on return stack->buffer is exclusively locked,
* and the stack represents the full path to the root. Otherwise stack->buffer
* is share-locked, and stack->parent is NULL.
+ *
+ * If 'rootConflictCheck' is true, tree root is checked for serialization
+ * conflict.
*/
GinBtreeStack *
-ginFindLeafPage(GinBtree btree, bool searchMode, Snapshot snapshot)
+ginFindLeafPage(GinBtree btree, bool searchMode,
+ bool rootConflictCheck, Snapshot snapshot)
{
GinBtreeStack *stack;
stack->parent = NULL;
stack->predictNumber = 1;
- if (!searchMode)
+ if (rootConflictCheck)
CheckForSerializableConflictIn(btree->index, NULL, stack->buffer);
for (;;)
{
/* search for the leaf page where the first item should go to */
btree.itemptr = insertdata.items[insertdata.curitem];
- stack = ginFindLeafPage(&btree, false, NULL);
+ stack = ginFindLeafPage(&btree, false, true, NULL);
ginInsertValue(&btree, stack, &insertdata, buildStats);
}
btree->fullScan = true;
- stack = ginFindLeafPage(btree, true, snapshot);
+ stack = ginFindLeafPage(btree, true, false, snapshot);
return stack;
}
ginPrepareEntryScan(&btreeEntry, entry->attnum,
entry->queryKey, entry->queryCategory,
ginstate);
- stackEntry = ginFindLeafPage(&btreeEntry, true, snapshot);
+ stackEntry = ginFindLeafPage(&btreeEntry, true, false, snapshot);
page = BufferGetPage(stackEntry->buffer);
/* ginFindLeafPage() will have already checked snapshot age. */
OffsetNumberNext(GinItemPointerGetOffsetNumber(&advancePast)));
}
entry->btree.fullScan = false;
- stack = ginFindLeafPage(&entry->btree, true, snapshot);
+ stack = ginFindLeafPage(&entry->btree, true, false, snapshot);
/* we don't need the stack, just the buffer. */
entry->buffer = stack->buffer;
ginPrepareEntryScan(&btree, attnum, key, category, ginstate);
- stack = ginFindLeafPage(&btree, false, NULL);
+ stack = ginFindLeafPage(&btree, false, false, NULL);
page = BufferGetPage(stack->buffer);
if (btree.findItem(&btree, stack))
* PostingItem
*/
-extern GinBtreeStack *ginFindLeafPage(GinBtree btree, bool searchMode, Snapshot snapshot);
+extern GinBtreeStack *ginFindLeafPage(GinBtree btree, bool searchMode,
+ bool rootConflictCheck, Snapshot snapshot);
extern Buffer ginStepRight(Buffer buffer, Relation index, int lockmode);
extern void freeGinBtreeStack(GinBtreeStack *stack);
extern void ginInsertValue(GinBtree btree, GinBtreeStack *stack,