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

Commit0b5c161

Browse files
committed
amcheck: Don't load the right sibling page into BtreeCheckState
5ae2087 implemented a cross-page unique constraint check by loadingthe right sibling to the BtreeCheckState.target variable. This is wrong,because bt_target_page_check() shouldn't change the target page. Also,BtreeCheckState.target shouldn't be changed alone withoutBtreeCheckState.targetblock.However, the above didn't cause any visible bugs for the following reasons.1. We do a cross-page unique constraint check only for leaf index pages.2. The only way target page get accessed after a cross-page unique constraint check is loading of the lowkey.3. The only place lowkey is used is bt_child_highkey_check(), and that applies only to non-leafs.The reasons above don't diminish the fact that changing BtreeCheckState.targetfor a cross-page unique constraint check is wrong. This commit changes thischeck to temporarily store the right sibling to the local variable.Reported-by: Peter GeogheganDiscussion:https://postgr.es/m/CAH2-Wzk%2B2116uOXdOViA27SHcr31WKPgmjsxXLBs_aTxAeThzg%40mail.gmail.comAuthor: Pavel Borisov
1 parent532d94f commit0b5c161

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

‎contrib/amcheck/verify_nbtree.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1892,20 +1892,24 @@ bt_target_page_check(BtreeCheckState *state)
18921892
/* The first key on the next page is the same */
18931893
if (_bt_compare(state->rel,rightkey,state->target,max)==0&& !rightkey->anynullkeys)
18941894
{
1895+
Pagerightpage;
1896+
18951897
elog(DEBUG2,"cross page equal keys");
1896-
state->target=palloc_btree_page(state,
1897-
rightblock_number);
1898-
topaque=BTPageGetOpaque(state->target);
1898+
rightpage=palloc_btree_page(state,
1899+
rightblock_number);
1900+
topaque=BTPageGetOpaque(rightpage);
18991901

19001902
if (P_IGNORE(topaque)|| !P_ISLEAF(topaque))
19011903
break;
19021904

19031905
itemid=PageGetItemIdCareful(state,rightblock_number,
1904-
state->target,
1906+
rightpage,
19051907
rightfirstoffset);
1906-
itup= (IndexTuple)PageGetItem(state->target,itemid);
1908+
itup= (IndexTuple)PageGetItem(rightpage,itemid);
19071909

19081910
bt_entry_unique_check(state,itup,rightblock_number,rightfirstoffset,&lVis);
1911+
1912+
pfree(rightpage);
19091913
}
19101914
}
19111915
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp