]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Fix nbtree page deletion error messages.
authorPeter Geoghegan <pg@bowt.ie>
Tue, 2 Mar 2021 21:02:24 +0000 (13:02 -0800)
committerPeter Geoghegan <pg@bowt.ie>
Tue, 2 Mar 2021 21:02:24 +0000 (13:02 -0800)
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.

src/backend/access/nbtree/nbtpage.c

index 629a23628ef6cb341d2de80caca5d26695c5085d..84ea7eac58e73910b8e12a692027a0fc61631451 100644 (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));