Skip to content

Commit 2ab2344

Browse files
Remove unneeded argument from _bt_getstackbuf().
_bt_getstackbuf() is called at exactly two points following commit efada2b (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.
1 parent 067786c commit 2ab2344

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/backend/access/nbtree/nbtinsert.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1886,7 +1886,7 @@ _bt_insert_parent(Relation rel,
18861886
* 05/27/97
18871887
*/
18881888
stack->bts_btentry = bknum;
1889-
pbuf = _bt_getstackbuf(rel, stack, BT_WRITE);
1889+
pbuf = _bt_getstackbuf(rel, stack);
18901890

18911891
/*
18921892
* 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)
19761976
*
19771977
* Adjusts bts_blkno & bts_offset if changed.
19781978
*
1979-
* Returns InvalidBuffer if item not found (should not happen).
1979+
* Returns write-locked buffer, or InvalidBuffer if item not found
1980+
* (should not happen).
19801981
*/
19811982
Buffer
1982-
_bt_getstackbuf(Relation rel, BTStack stack, int access)
1983+
_bt_getstackbuf(Relation rel, BTStack stack)
19831984
{
19841985
BlockNumber blkno;
19851986
OffsetNumber start;
@@ -1993,11 +1994,11 @@ _bt_getstackbuf(Relation rel, BTStack stack, int access)
19931994
Page page;
19941995
BTPageOpaque opaque;
19951996

1996-
buf = _bt_getbuf(rel, blkno, access);
1997+
buf = _bt_getbuf(rel, blkno, BT_WRITE);
19971998
page = BufferGetPage(buf);
19981999
opaque = (BTPageOpaque) PageGetSpecialPointer(page);
19992000

2000-
if (access == BT_WRITE && P_INCOMPLETE_SPLIT(opaque))
2001+
if (P_INCOMPLETE_SPLIT(opaque))
20012002
{
20022003
_bt_finish_split(rel, buf, stack->bts_parent);
20032004
continue;

src/backend/access/nbtree/nbtpage.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,7 @@ _bt_lock_branch_parent(Relation rel, BlockNumber child, BTStack stack,
11531153
* if needed)
11541154
*/
11551155
stack->bts_btentry = child;
1156-
pbuf = _bt_getstackbuf(rel, stack, BT_WRITE);
1156+
pbuf = _bt_getstackbuf(rel, stack);
11571157
if (pbuf == InvalidBuffer)
11581158
elog(ERROR, "failed to re-find parent key in index \"%s\" for deletion target page %u",
11591159
RelationGetRelationName(rel), child);

src/include/access/nbtree.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ extern void _bt_parallel_advance_array_keys(IndexScanDesc scan);
528528
*/
529529
extern bool _bt_doinsert(Relation rel, IndexTuple itup,
530530
IndexUniqueCheck checkUnique, Relation heapRel);
531-
extern Buffer _bt_getstackbuf(Relation rel, BTStack stack, int access);
531+
extern Buffer _bt_getstackbuf(Relation rel, BTStack stack);
532532
extern void _bt_finish_split(Relation rel, Buffer bbuf, BTStack stack);
533533

534534
/*

0 commit comments

Comments
 (0)