Fix amcheck's handling of incomplete root splits in B-tree
authorHeikki Linnakangas <[email protected]>
Tue, 2 Dec 2025 19:10:51 +0000 (21:10 +0200)
committerHeikki Linnakangas <[email protected]>
Tue, 2 Dec 2025 19:15:43 +0000 (21:15 +0200)
When the root page is being split, it's normal that root page
according to the metapage is not marked BTP_ROOT. Fix bogus error in
amcheck about that case.

Reviewed-by: Peter Geoghegan <[email protected]>
Discussion: https://www.postgresql.org/message-id/abd65090-5336-42cc-b768-2bdd66738404@iki.fi
Backpatch-through: 14

contrib/amcheck/verify_nbtree.c

index d92a946622400acd0d15ceb3a702d0d9ce05f54d..b37f6790458fe784e5bd5074a0790b10f36d7076 100644 (file)
@@ -786,7 +786,7 @@ bt_check_level_from_leftmost(BtreeCheckState *state, BtreeLevel level)
                             errmsg("block %u is not leftmost in index \"%s\"",
                                    current, RelationGetRelationName(state->rel))));
 
-               if (level.istruerootlevel && !P_ISROOT(opaque))
+               if (level.istruerootlevel && (!P_ISROOT(opaque) && !P_INCOMPLETE_SPLIT(opaque)))
                    ereport(ERROR,
                            (errcode(ERRCODE_INDEX_CORRUPTED),
                             errmsg("block %u is not true root in index \"%s\"",