Fix longstanding bug found by Atsushi Ogawa: _bt_check_unique would mark
authorTom Lane <[email protected]>
Wed, 12 Oct 2005 17:18:15 +0000 (17:18 +0000)
committerTom Lane <[email protected]>
Wed, 12 Oct 2005 17:18:15 +0000 (17:18 +0000)
the wrong buffer dirty when trying to kill a dead index entry that's on
a page after the one it started on.  No risk of data corruption, just
inefficiency, but still a bug.

src/backend/access/nbtree/nbtinsert.c

index c14d554752139c3181ee403609d726054dbbb9f6..2f3edc3043476cf61484e0e49d457f09d6ab74f7 100644 (file)
@@ -266,7 +266,10 @@ _bt_check_unique(Relation rel, BTItem btitem, Relation heapRel,
                                                                                                 hbuffer) == HEAPTUPLE_DEAD)
                                        {
                                                curitemid->lp_flags |= LP_DELETE;
-                                               SetBufferCommitInfoNeedsSave(buf);
+                                               if (nbuf != InvalidBuffer)
+                                                       SetBufferCommitInfoNeedsSave(nbuf);
+                                               else
+                                                       SetBufferCommitInfoNeedsSave(buf);
                                        }
                                        LockBuffer(hbuffer, BUFFER_LOCK_UNLOCK);
                                }