Remove unneeded argument from _bt_getstackbuf().

_bt_getstackbuf() is called at exactly two points following commit
efada2b8e9 (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.
This commit is contained in:
Peter Geoghegan 2019-02-25 17:47:43 -08:00
parent 067786cea0
commit 2ab23445bc
3 changed files with 8 additions and 7 deletions

View 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;

View 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);

View 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);
/*