]> granicus.if.org Git - postgresql/commitdiff
Fix setting of right bound at GIN page split.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 7 Nov 2013 17:36:52 +0000 (19:36 +0200)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 7 Nov 2013 17:45:07 +0000 (19:45 +0200)
Broken by my refactoring.

src/backend/access/gin/gindatapage.c

index d67e50555ca43e63caca8910c0fb1ea94fabe1b4..049db38a2bf9c2bc1ec6a1aec1d38228a898fa3e 100644 (file)
@@ -548,7 +548,12 @@ dataSplitPage(GinBtree btree, Buffer lbuf, Buffer rbuf, OffsetNumber off, XLogRe
 
        /* set up right bound for left page */
        bound = GinDataPageGetRightBound(lpage);
-       *bound = btree->pitem.key;
+       if (GinPageIsLeaf(lpage))
+               *bound = *GinDataPageGetItemPointer(lpage,
+                                                                                       GinPageGetOpaque(lpage)->maxoff);
+       else
+               *bound = GinDataPageGetPostingItem(lpage,
+                                                                         GinPageGetOpaque(lpage)->maxoff)->key;
 
        /* set up right bound for right page */
        bound = GinDataPageGetRightBound(rpage);
@@ -577,12 +582,7 @@ dataSplitPage(GinBtree btree, Buffer lbuf, Buffer rbuf, OffsetNumber off, XLogRe
 
        /* Prepare a downlink tuple for insertion to the parent */
        PostingItemSetBlockNumber(&(btree->pitem), BufferGetBlockNumber(lbuf));
-       if (GinPageIsLeaf(lpage))
-               btree->pitem.key = *GinDataPageGetItemPointer(lpage,
-                                                                                       GinPageGetOpaque(lpage)->maxoff);
-       else
-               btree->pitem.key = GinDataPageGetPostingItem(lpage,
-                                                                         GinPageGetOpaque(lpage)->maxoff)->key;
+       btree->pitem.key = *GinDataPageGetRightBound(lpage);
        btree->rightblkno = BufferGetBlockNumber(rbuf);
 
        return lpage;