Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 826ee1a

Browse files
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().
1 parent d60cfb6 commit 826ee1a

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/backend/access/nbtree/nbtinsert.c

+10-11
Original file line numberDiff line numberDiff line change
@@ -1266,8 +1266,11 @@ _bt_insertonpg(Relation rel,
12661266
MarkBufferDirty(metabuf);
12671267
}
12681268

1269-
/* clear INCOMPLETE_SPLIT flag on child if inserting a downlink */
1270-
if (BufferIsValid(cbuf))
1269+
/*
1270+
* Clear INCOMPLETE_SPLIT flag on child if inserting the new item
1271+
* finishes a split
1272+
*/
1273+
if (!isleaf)
12711274
{
12721275
Page cpage = BufferGetPage(cbuf);
12731276
BTPageOpaque cpageop = (BTPageOpaque) PageGetSpecialPointer(cpage);
@@ -1305,13 +1308,9 @@ _bt_insertonpg(Relation rel,
13051308
}
13061309
else
13071310
{
1308-
/*
1309-
* Register the left child whose INCOMPLETE_SPLIT flag was
1310-
* cleared.
1311-
*/
1312-
XLogRegisterBuffer(1, cbuf, REGBUF_STANDARD);
1313-
1311+
/* Internal page insert, which finishes a split on cbuf */
13141312
xlinfo = XLOG_BTREE_INSERT_UPPER;
1313+
XLogRegisterBuffer(1, cbuf, REGBUF_STANDARD);
13151314
}
13161315

13171316
if (BufferIsValid(metabuf))
@@ -1360,7 +1359,7 @@ _bt_insertonpg(Relation rel,
13601359

13611360
if (BufferIsValid(metabuf))
13621361
PageSetLSN(metapg, recptr);
1363-
if (BufferIsValid(cbuf))
1362+
if (!isleaf)
13641363
PageSetLSN(BufferGetPage(cbuf), recptr);
13651364

13661365
PageSetLSN(page, recptr);
@@ -1371,7 +1370,7 @@ _bt_insertonpg(Relation rel,
13711370
/* Release subsidiary buffers */
13721371
if (BufferIsValid(metabuf))
13731372
_bt_relbuf(rel, metabuf);
1374-
if (BufferIsValid(cbuf))
1373+
if (!isleaf)
13751374
_bt_relbuf(rel, cbuf);
13761375

13771376
/*
@@ -1928,7 +1927,7 @@ _bt_split(Relation rel, BTScanInsert itup_key, Buffer buf, Buffer cbuf,
19281927

19291928
/*
19301929
* Clear INCOMPLETE_SPLIT flag on child if inserting the new item finishes
1931-
* a split.
1930+
* a split
19321931
*/
19331932
if (!isleaf)
19341933
{

0 commit comments

Comments
 (0)