diff options
author | Peter Geoghegan <pg@bowt.ie> | 2020-04-13 19:26:41 -0700 |
---|---|---|
committer | Peter Geoghegan <pg@bowt.ie> | 2020-04-13 19:26:41 -0700 |
commit | 826ee1a019127d611bb0fd22ca878142bfb077ac (patch) | |
tree | c1b7d8c5426571b3edcf07c86bde3bcc292e80ce | |
parent | d60cfb6bf2b4812e97271e7b5ba3ad4713406b9d (diff) | |
download | postgresql-826ee1a019127d611bb0fd22ca878142bfb077ac.tar.gz postgresql-826ee1a019127d611bb0fd22ca878142bfb077ac.zip |
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().
-rw-r--r-- | src/backend/access/nbtree/nbtinsert.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/backend/access/nbtree/nbtinsert.c b/src/backend/access/nbtree/nbtinsert.c index fd518d3ea5a..4fa2e85877a 100644 --- a/src/backend/access/nbtree/nbtinsert.c +++ b/src/backend/access/nbtree/nbtinsert.c @@ -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) { |