Fix bug in new B-tree page deletion code.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 22 Apr 2014 12:34:54 +0000 (15:34 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Tue, 22 Apr 2014 12:34:54 +0000 (15:34 +0300)
When modifying a page, must hold an exclusive lock. A shared lock is
obviously not good enough.

src/backend/access/nbtree/nbtpage.c

index 87ac5f4aafba7db496470cbbb3c19a27707373d7..b95c1b886d4df4bd28df74848701f28df3b06ac8 100644 (file)
@@ -996,7 +996,7 @@ _bt_lock_branch_parent(Relation rel, BlockNumber child, BTStack stack,
 
    /* Locate the parent's downlink (updating the stack entry if needed) */
    ItemPointerSet(&(stack->bts_btentry.t_tid), child, P_HIKEY);
-   pbuf = _bt_getstackbuf(rel, stack, BT_READ);
+   pbuf = _bt_getstackbuf(rel, stack, BT_WRITE);
    if (pbuf == InvalidBuffer)
        elog(ERROR, "failed to re-find parent key in index \"%s\" for deletion target page %u",
             RelationGetRelationName(rel), child);