Fix nbtree page deletion error messages.

Adjust some "can't happen" error messages that assumed that the page
deletion target page must be a half-dead page.  This assumption was
wrong in the case of an internal target page.  Simply refer to these
pages as the target page instead.

Internal pages are never marked half-dead.  There is exactly one
half-dead page for each subtree undergoing deletion.  The half-dead page
is also the target subtree's leaf-level page.  This has been the case
since commit efada2b8, which totally overhauled nbtree page deletion.
This commit is contained in:
Peter Geoghegan 2021-03-02 13:02:24 -08:00
parent d16f8c8e41
commit 3d8d5787a3
1 changed files with 7 additions and 6 deletions

View File

@ -2420,20 +2420,21 @@ _bt_unlink_halfdead_page(Relation rel, Buffer leafbuf, BlockNumber scanblkno,
* only one vacuum process running at a time.
*/
if (P_RIGHTMOST(opaque) || P_ISROOT(opaque) || P_ISDELETED(opaque))
elog(ERROR, "half-dead page changed status unexpectedly in block %u of index \"%s\"",
elog(ERROR, "target page changed status unexpectedly in block %u of index \"%s\"",
target, RelationGetRelationName(rel));
if (opaque->btpo_prev != leftsib)
ereport(ERROR,
(errcode(ERRCODE_INDEX_CORRUPTED),
errmsg_internal("left link changed unexpectedly in block %u of index \"%s\"",
target, RelationGetRelationName(rel))));
errmsg_internal("target page left link unexpectedly changed from %u to %u in block %u of index \"%s\"",
leftsib, opaque->btpo_prev, target,
RelationGetRelationName(rel))));
if (target == leafblkno)
{
if (P_FIRSTDATAKEY(opaque) <= PageGetMaxOffsetNumber(page) ||
!P_ISLEAF(opaque) || !P_ISHALFDEAD(opaque))
elog(ERROR, "half-dead page changed status unexpectedly in block %u of index \"%s\"",
elog(ERROR, "target leaf page changed status unexpectedly in block %u of index \"%s\"",
target, RelationGetRelationName(rel));
/* Leaf page is also target page: don't set leaftopparent */
@ -2445,8 +2446,8 @@ _bt_unlink_halfdead_page(Relation rel, Buffer leafbuf, BlockNumber scanblkno,
if (P_FIRSTDATAKEY(opaque) != PageGetMaxOffsetNumber(page) ||
P_ISLEAF(opaque))
elog(ERROR, "half-dead page changed status unexpectedly in block %u of index \"%s\"",
target, RelationGetRelationName(rel));
elog(ERROR, "target internal page on level %u changed status unexpectedly in block %u of index \"%s\"",
targetlevel, target, RelationGetRelationName(rel));
/* Target is internal: set leaftopparent for next call here... */
itemid = PageGetItemId(page, P_FIRSTDATAKEY(opaque));