diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2012-07-13 11:37:39 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2012-07-13 11:37:39 -0400 |
commit | 1a9405d26537c6d95269bf48f5ea80fbf7967260 (patch) | |
tree | b0860adf6848e82d7457e5237c4d1f8a871e4e3a /src/backend/access/gin/ginbtree.c | |
parent | a84bf4922e566f047536112a2aaf488559ee62dd (diff) | |
download | postgresql-1a9405d26537c6d95269bf48f5ea80fbf7967260.tar.gz postgresql-1a9405d26537c6d95269bf48f5ea80fbf7967260.zip |
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
Diffstat (limited to 'src/backend/access/gin/ginbtree.c')
-rw-r--r-- | src/backend/access/gin/ginbtree.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/backend/access/gin/ginbtree.c b/src/backend/access/gin/ginbtree.c index b160551b5ed..82ac53e1487 100644 --- a/src/backend/access/gin/ginbtree.c +++ b/src/backend/access/gin/ginbtree.c @@ -275,20 +275,22 @@ ginFindParents(GinBtree btree, GinBtreeStack *stack, void ginInsertValue(GinBtree btree, GinBtreeStack *stack, GinStatsData *buildStats) { - GinBtreeStack *parent = stack; - BlockNumber rootBlkno = InvalidBuffer; + GinBtreeStack *parent; + BlockNumber rootBlkno; Page page, rpage, lpage; - /* remember root BlockNumber */ - while (parent) - { - rootBlkno = parent->blkno; + /* extract root BlockNumber from stack */ + Assert(stack != NULL); + parent = stack; + while (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; BlockNumber savedRightLink; @@ -457,7 +459,7 @@ ginInsertValue(GinBtree btree, GinBtreeStack *stack, GinStatsData *buildStats) */ ginFindParents(btree, stack, rootBlkno); parent = stack->parent; - page = BufferGetPage(parent->buffer); + Assert(parent != NULL); break; } |