Commit 1a9405d2 authored by Tom Lane's avatar Tom Lane

Cosmetic cleanup of ginInsertValue().

Make it clearer that the passed stack mustn't be empty, and that we
are not supposed to fall off the end of the stack in the main loop.
Tighten the loop that extracts the root block number, too.

Markus Wanner and Tom Lane
parent a84bf492
...@@ -275,20 +275,22 @@ ginFindParents(GinBtree btree, GinBtreeStack *stack, ...@@ -275,20 +275,22 @@ ginFindParents(GinBtree btree, GinBtreeStack *stack,
void void
ginInsertValue(GinBtree btree, GinBtreeStack *stack, GinStatsData *buildStats) ginInsertValue(GinBtree btree, GinBtreeStack *stack, GinStatsData *buildStats)
{ {
GinBtreeStack *parent = stack; GinBtreeStack *parent;
BlockNumber rootBlkno = InvalidBuffer; BlockNumber rootBlkno;
Page page, Page page,
rpage, rpage,
lpage; lpage;
/* remember root BlockNumber */ /* extract root BlockNumber from stack */
while (parent) Assert(stack != NULL);
{ parent = stack;
rootBlkno = parent->blkno; while (parent->parent)
parent = parent->parent; parent = parent->parent;
} rootBlkno = parent->blkno;
Assert(BlockNumberIsValid(rootBlkno));
while (stack) /* this loop crawls up the stack until the insertion is complete */
for (;;)
{ {
XLogRecData *rdata; XLogRecData *rdata;
BlockNumber savedRightLink; BlockNumber savedRightLink;
...@@ -457,7 +459,7 @@ ginInsertValue(GinBtree btree, GinBtreeStack *stack, GinStatsData *buildStats) ...@@ -457,7 +459,7 @@ ginInsertValue(GinBtree btree, GinBtreeStack *stack, GinStatsData *buildStats)
*/ */
ginFindParents(btree, stack, rootBlkno); ginFindParents(btree, stack, rootBlkno);
parent = stack->parent; parent = stack->parent;
page = BufferGetPage(parent->buffer); Assert(parent != NULL);
break; break;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment