amcheck: Fixes for right page check during unique constraint check

* Don't forget to pfree() the right page when it's to be ignored.
 * Report error on unexpected non-leaf right page even if this page is not
   to be ignored.  This restores the logic which was unintendedly changed
   in 97e5b0026f.

Reported-by: Pavel Borisov
This commit is contained in:
Alexander Korotkov 2024-05-26 07:14:12 +03:00
parent 4cf9aab214
commit 945ec4c4bc
1 changed files with 12 additions and 10 deletions

View File

@ -1901,17 +1901,19 @@ bt_target_page_check(BtreeCheckState *state)
if (P_IGNORE(topaque))
{
if (unlikely(!P_ISLEAF(topaque)))
ereport(ERROR,
(errcode(ERRCODE_INDEX_CORRUPTED),
errmsg("right block of leaf block is non-leaf for index \"%s\"",
RelationGetRelationName(state->rel)),
errdetail_internal("Block=%u page lsn=%X/%X.",
state->targetblock,
LSN_FORMAT_ARGS(state->targetlsn))));
else
break;
pfree(rightpage);
break;
}
if (unlikely(!P_ISLEAF(topaque)))
ereport(ERROR,
(errcode(ERRCODE_INDEX_CORRUPTED),
errmsg("right block of leaf block is non-leaf for index \"%s\"",
RelationGetRelationName(state->rel)),
errdetail_internal("Block=%u page lsn=%X/%X.",
state->targetblock,
LSN_FORMAT_ARGS(state->targetlsn))));
itemid = PageGetItemIdCareful(state, rightblock_number,
rightpage,
rightfirstoffset);