]> granicus.if.org Git - postgresql/commitdiff
Remove unneeded argument from _bt_getstackbuf().
authorPeter Geoghegan <pg@bowt.ie>
Tue, 26 Feb 2019 01:47:43 +0000 (17:47 -0800)
committerPeter Geoghegan <pg@bowt.ie>
Tue, 26 Feb 2019 01:47:43 +0000 (17:47 -0800)
_bt_getstackbuf() is called at exactly two points following commit
efada2b8e92 (one call site is concerned with page splits, while the
other is concerned with page deletion).  The parent buffer returned by
_bt_getstackbuf() is write-locked in both cases.  Remove the 'access'
argument and make _bt_getstackbuf() assume that callers require a
write-lock.

src/backend/access/nbtree/nbtinsert.c
src/backend/access/nbtree/nbtpage.c
src/include/access/nbtree.h

index 5c2b8034f5eaf42a048493517cca8a8fc0857123..a4d46a0f446451052b32a3064a71790fa4268b4b 100644 (file)
@@ -1886,7 +1886,7 @@ _bt_insert_parent(Relation rel,
                 * 05/27/97
                 */
                stack->bts_btentry = bknum;
-               pbuf = _bt_getstackbuf(rel, stack, BT_WRITE);
+               pbuf = _bt_getstackbuf(rel, stack);
 
                /*
                 * Now we can unlock the right child. The left child will be unlocked
@@ -1976,10 +1976,11 @@ _bt_finish_split(Relation rel, Buffer lbuf, BTStack stack)
  *
  *             Adjusts bts_blkno & bts_offset if changed.
  *
- *             Returns InvalidBuffer if item not found (should not happen).
+ *             Returns write-locked buffer, or InvalidBuffer if item not found
+ *             (should not happen).
  */
 Buffer
-_bt_getstackbuf(Relation rel, BTStack stack, int access)
+_bt_getstackbuf(Relation rel, BTStack stack)
 {
        BlockNumber blkno;
        OffsetNumber start;
@@ -1993,11 +1994,11 @@ _bt_getstackbuf(Relation rel, BTStack stack, int access)
                Page            page;
                BTPageOpaque opaque;
 
-               buf = _bt_getbuf(rel, blkno, access);
+               buf = _bt_getbuf(rel, blkno, BT_WRITE);
                page = BufferGetPage(buf);
                opaque = (BTPageOpaque) PageGetSpecialPointer(page);
 
-               if (access == BT_WRITE && P_INCOMPLETE_SPLIT(opaque))
+               if (P_INCOMPLETE_SPLIT(opaque))
                {
                        _bt_finish_split(rel, buf, stack->bts_parent);
                        continue;
index 300daf915da6a6ffc2c8f74c78f27565077d7571..9c785bca95e35f956d9be55cb995923204ce84f8 100644 (file)
@@ -1153,7 +1153,7 @@ _bt_lock_branch_parent(Relation rel, BlockNumber child, BTStack stack,
         * if needed)
         */
        stack->bts_btentry = child;
-       pbuf = _bt_getstackbuf(rel, stack, BT_WRITE);
+       pbuf = _bt_getstackbuf(rel, stack);
        if (pbuf == InvalidBuffer)
                elog(ERROR, "failed to re-find parent key in index \"%s\" for deletion target page %u",
                         RelationGetRelationName(rel), child);
index 4fb92d60a12c3c435935f946ad1fa3ba8623bbd3..60622ea7906a0c23397de99a4d9281da408a6e52 100644 (file)
@@ -528,7 +528,7 @@ extern void _bt_parallel_advance_array_keys(IndexScanDesc scan);
  */
 extern bool _bt_doinsert(Relation rel, IndexTuple itup,
                         IndexUniqueCheck checkUnique, Relation heapRel);
-extern Buffer _bt_getstackbuf(Relation rel, BTStack stack, int access);
+extern Buffer _bt_getstackbuf(Relation rel, BTStack stack);
 extern void _bt_finish_split(Relation rel, Buffer bbuf, BTStack stack);
 
 /*