summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Geoghegan2020-03-18 01:39:26 +0000
committerPeter Geoghegan2020-03-18 01:39:26 +0000
commitb897b3aae6b525922fe3d074d4bdf5f2674954dd (patch)
tree072e3e07882d59eabfdab2c4d445bc5f990f758e
parent9b8aa0929390aab1f2f0859016e6110d283732dd (diff)
nbtree: Remove useless local variables.
Copying block and offset numbers to local variables in _bt_insertonpg() made the code less readable. Remove the variables. There is already code that conditionally calls BufferGetBlockNumber() in the same block, so consistently do it that way instead. Calling BufferGetBlockNumber() is very cheap, but we might as well avoid it when it isn't truly necessary. It isn't truly necessary for _bt_insertonpg() to call BufferGetBlockNumber() in almost all cases. Spotted while working on a patch that refactors the fastpath rightmost leaf page cache optimization, which was added by commit 2b272734.
-rw-r--r--src/backend/access/nbtree/nbtinsert.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/backend/access/nbtree/nbtinsert.c b/src/backend/access/nbtree/nbtinsert.c
index f503be64224..966c0bb532f 100644
--- a/src/backend/access/nbtree/nbtinsert.c
+++ b/src/backend/access/nbtree/nbtinsert.c
@@ -1180,13 +1180,8 @@ _bt_insertonpg(Relation rel,
Buffer metabuf = InvalidBuffer;
Page metapg = NULL;
BTMetaPageData *metad = NULL;
- OffsetNumber itup_off;
- BlockNumber itup_blkno;
BlockNumber cachedBlock = InvalidBlockNumber;
- itup_off = newitemoff;
- itup_blkno = BufferGetBlockNumber(buf);
-
/*
* If we are doing this insert because we split a page that was the
* only one on its tree level, but was not the root, it may have been
@@ -1218,7 +1213,7 @@ _bt_insertonpg(Relation rel,
if (!_bt_pgaddtup(page, itemsz, itup, newitemoff))
elog(PANIC, "failed to add new item to block %u in index \"%s\"",
- itup_blkno, RelationGetRelationName(rel));
+ BufferGetBlockNumber(buf), RelationGetRelationName(rel));
MarkBufferDirty(buf);
@@ -1227,7 +1222,7 @@ _bt_insertonpg(Relation rel,
/* upgrade meta-page if needed */
if (metad->btm_version < BTREE_NOVAC_VERSION)
_bt_upgrademetapage(metapg);
- metad->btm_fastroot = itup_blkno;
+ metad->btm_fastroot = BufferGetBlockNumber(buf);
metad->btm_fastlevel = lpageop->btpo.level;
MarkBufferDirty(metabuf);
}
@@ -1260,7 +1255,7 @@ _bt_insertonpg(Relation rel,
uint8 xlinfo;
XLogRecPtr recptr;
- xlrec.offnum = itup_off;
+ xlrec.offnum = newitemoff;
XLogBeginInsert();
XLogRegisterData((char *) &xlrec, SizeOfBtreeInsert);