Make _bt_insertonpg() more like _bt_split().

It seems like a good idea for nbtree's retail insert code to be
absolutely consistent with nbtree's page split code for anything that
naturally requires equivalent handling.  Anything that concerns
inserting newitem (which is handled as part of the page split atomic
action when a page split is required) should work in exactly the same
way.  With that in mind, make _bt_insertonpg() handle 'cbuf' in a way
that matches _bt_split().
This commit is contained in:
Peter Geoghegan 2020-04-13 19:26:41 -07:00
parent d60cfb6bf2
commit 826ee1a019
1 changed files with 10 additions and 11 deletions

View File

@ -1266,8 +1266,11 @@ _bt_insertonpg(Relation rel,
MarkBufferDirty(metabuf);
}
/* clear INCOMPLETE_SPLIT flag on child if inserting a downlink */
if (BufferIsValid(cbuf))
/*
* Clear INCOMPLETE_SPLIT flag on child if inserting the new item
* finishes a split
*/
if (!isleaf)
{
Page cpage = BufferGetPage(cbuf);
BTPageOpaque cpageop = (BTPageOpaque) PageGetSpecialPointer(cpage);
@ -1305,13 +1308,9 @@ _bt_insertonpg(Relation rel,
}
else
{
/*
* Register the left child whose INCOMPLETE_SPLIT flag was
* cleared.
*/
XLogRegisterBuffer(1, cbuf, REGBUF_STANDARD);
/* Internal page insert, which finishes a split on cbuf */
xlinfo = XLOG_BTREE_INSERT_UPPER;
XLogRegisterBuffer(1, cbuf, REGBUF_STANDARD);
}
if (BufferIsValid(metabuf))
@ -1360,7 +1359,7 @@ _bt_insertonpg(Relation rel,
if (BufferIsValid(metabuf))
PageSetLSN(metapg, recptr);
if (BufferIsValid(cbuf))
if (!isleaf)
PageSetLSN(BufferGetPage(cbuf), recptr);
PageSetLSN(page, recptr);
@ -1371,7 +1370,7 @@ _bt_insertonpg(Relation rel,
/* Release subsidiary buffers */
if (BufferIsValid(metabuf))
_bt_relbuf(rel, metabuf);
if (BufferIsValid(cbuf))
if (!isleaf)
_bt_relbuf(rel, cbuf);
/*
@ -1928,7 +1927,7 @@ _bt_split(Relation rel, BTScanInsert itup_key, Buffer buf, Buffer cbuf,
/*
* Clear INCOMPLETE_SPLIT flag on child if inserting the new item finishes
* a split.
* a split
*/
if (!isleaf)
{