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

Commitc73669c

Browse files
committed
Fix WAL-logging of B-tree "unlink halfdead page" operation.
There was some confusion on how to record the case that the operationunlinks the last non-leaf page in the branch being deleted._bt_unlink_halfdead_page set the "topdead" field in the WAL record tothe leaf page, but the redo routine assumed that it would be an invalidblock number in that case. This commit fixes _bt_unlink_halfdead_page todo what the redo routine expected.This code is new in 9.4, so backpatch there.
1 parent0f9692b commitc73669c

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

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

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1567,7 +1567,6 @@ _bt_unlink_halfdead_page(Relation rel, Buffer leafbuf, bool *rightsib_empty)
15671567
inttargetlevel;
15681568
ItemPointerleafhikey;
15691569
BlockNumbernextchild;
1570-
BlockNumbertopblkno;
15711570

15721571
page=BufferGetPage(leafbuf);
15731572
opaque= (BTPageOpaque)PageGetSpecialPointer(page);
@@ -1591,11 +1590,10 @@ _bt_unlink_halfdead_page(Relation rel, Buffer leafbuf, bool *rightsib_empty)
15911590
*/
15921591
if (ItemPointerIsValid(leafhikey))
15931592
{
1594-
topblkno=ItemPointerGetBlockNumber(leafhikey);
1595-
target=topblkno;
1593+
target=ItemPointerGetBlockNumber(leafhikey);
15961594

15971595
/* fetch the block number of the topmost parent's left sibling */
1598-
buf=_bt_getbuf(rel,topblkno,BT_READ);
1596+
buf=_bt_getbuf(rel,target,BT_READ);
15991597
page=BufferGetPage(buf);
16001598
opaque= (BTPageOpaque)PageGetSpecialPointer(page);
16011599
leftsib=opaque->btpo_prev;
@@ -1609,7 +1607,6 @@ _bt_unlink_halfdead_page(Relation rel, Buffer leafbuf, bool *rightsib_empty)
16091607
}
16101608
else
16111609
{
1612-
topblkno=InvalidBlockNumber;
16131610
target=leafblkno;
16141611

16151612
buf=leafbuf;
@@ -1694,9 +1691,11 @@ _bt_unlink_halfdead_page(Relation rel, Buffer leafbuf, bool *rightsib_empty)
16941691
elog(ERROR,"half-dead page changed status unexpectedly in block %u of index \"%s\"",
16951692
target,RelationGetRelationName(rel));
16961693

1697-
/* remember the next child down in the branch. */
1694+
/* remember the nextnon-leafchild down in the branch. */
16981695
itemid=PageGetItemId(page,P_FIRSTDATAKEY(opaque));
16991696
nextchild=ItemPointerGetBlockNumber(&((IndexTuple)PageGetItem(page,itemid))->t_tid);
1697+
if (nextchild==leafblkno)
1698+
nextchild=InvalidBlockNumber;
17001699
}
17011700

17021701
/*
@@ -1782,7 +1781,7 @@ _bt_unlink_halfdead_page(Relation rel, Buffer leafbuf, bool *rightsib_empty)
17821781
*/
17831782
if (target!=leafblkno)
17841783
{
1785-
if (nextchild==leafblkno)
1784+
if (nextchild==InvalidBlockNumber)
17861785
ItemPointerSetInvalid(leafhikey);
17871786
else
17881787
ItemPointerSet(leafhikey,nextchild,P_HIKEY);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp