Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit826ee1a

Browse files
Make _bt_insertonpg() more like _bt_split().
It seems like a good idea for nbtree's retail insert code to beabsolutely consistent with nbtree's page split code for anything thatnaturally requires equivalent handling. Anything that concernsinserting newitem (which is handled as part of the page split atomicaction when a page split is required) should work in exactly the sameway. With that in mind, make _bt_insertonpg() handle 'cbuf' in a waythat matches _bt_split().
1 parentd60cfb6 commit826ee1a

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

‎src/backend/access/nbtree/nbtinsert.c

Lines changed: 10 additions & 11 deletions
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
Pagecpage=BufferGetPage(cbuf);
12731276
BTPageOpaquecpageop= (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)

[8]ページ先頭

©2009-2025 Movatter.jp