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

Commit8607fdf

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 parentd8a7cdd commit8607fdf

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
@@ -1565,7 +1565,6 @@ _bt_unlink_halfdead_page(Relation rel, Buffer leafbuf, bool *rightsib_empty)
15651565
inttargetlevel;
15661566
ItemPointerleafhikey;
15671567
BlockNumbernextchild;
1568-
BlockNumbertopblkno;
15691568

15701569
page=BufferGetPage(leafbuf);
15711570
opaque= (BTPageOpaque)PageGetSpecialPointer(page);
@@ -1589,11 +1588,10 @@ _bt_unlink_halfdead_page(Relation rel, Buffer leafbuf, bool *rightsib_empty)
15891588
*/
15901589
if (ItemPointerIsValid(leafhikey))
15911590
{
1592-
topblkno=ItemPointerGetBlockNumber(leafhikey);
1593-
target=topblkno;
1591+
target=ItemPointerGetBlockNumber(leafhikey);
15941592

15951593
/* fetch the block number of the topmost parent's left sibling */
1596-
buf=_bt_getbuf(rel,topblkno,BT_READ);
1594+
buf=_bt_getbuf(rel,target,BT_READ);
15971595
page=BufferGetPage(buf);
15981596
opaque= (BTPageOpaque)PageGetSpecialPointer(page);
15991597
leftsib=opaque->btpo_prev;
@@ -1607,7 +1605,6 @@ _bt_unlink_halfdead_page(Relation rel, Buffer leafbuf, bool *rightsib_empty)
16071605
}
16081606
else
16091607
{
1610-
topblkno=InvalidBlockNumber;
16111608
target=leafblkno;
16121609

16131610
buf=leafbuf;
@@ -1692,9 +1689,11 @@ _bt_unlink_halfdead_page(Relation rel, Buffer leafbuf, bool *rightsib_empty)
16921689
elog(ERROR,"half-dead page changed status unexpectedly in block %u of index \"%s\"",
16931690
target,RelationGetRelationName(rel));
16941691

1695-
/* remember the next child down in the branch. */
1692+
/* remember the nextnon-leafchild down in the branch. */
16961693
itemid=PageGetItemId(page,P_FIRSTDATAKEY(opaque));
16971694
nextchild=ItemPointerGetBlockNumber(&((IndexTuple)PageGetItem(page,itemid))->t_tid);
1695+
if (nextchild==leafblkno)
1696+
nextchild=InvalidBlockNumber;
16981697
}
16991698

17001699
/*
@@ -1780,7 +1779,7 @@ _bt_unlink_halfdead_page(Relation rel, Buffer leafbuf, bool *rightsib_empty)
17801779
*/
17811780
if (target!=leafblkno)
17821781
{
1783-
if (nextchild==leafblkno)
1782+
if (nextchild==InvalidBlockNumber)
17841783
ItemPointerSetInvalid(leafhikey);
17851784
else
17861785
ItemPointerSet(leafhikey,nextchild,P_HIKEY);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp