mirror of
https://github.com/postgres/postgres.git
synced 2025-12-19 17:02:53 +03:00
Fix amcheck's handling of incomplete root splits in B-tree
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 <pg@bowt.ie> Discussion: https://www.postgresql.org/message-id/abd65090-5336-42cc-b768-2bdd66738404@iki.fi Backpatch-through: 14
This commit is contained in:
@@ -721,7 +721,7 @@ bt_check_level_from_leftmost(BtreeCheckState *state, BtreeLevel level)
|
|||||||
errmsg("block %u is not leftmost in index \"%s\"",
|
errmsg("block %u is not leftmost in index \"%s\"",
|
||||||
current, RelationGetRelationName(state->rel))));
|
current, RelationGetRelationName(state->rel))));
|
||||||
|
|
||||||
if (level.istruerootlevel && !P_ISROOT(opaque))
|
if (level.istruerootlevel && (!P_ISROOT(opaque) && !P_INCOMPLETE_SPLIT(opaque)))
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_INDEX_CORRUPTED),
|
(errcode(ERRCODE_INDEX_CORRUPTED),
|
||||||
errmsg("block %u is not true root in index \"%s\"",
|
errmsg("block %u is not true root in index \"%s\"",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# src/test/modules/nbtree/Makefile
|
# src/test/modules/nbtree/Makefile
|
||||||
|
|
||||||
EXTRA_INSTALL = src/test/modules/injection_points
|
EXTRA_INSTALL = src/test/modules/injection_points contrib/amcheck
|
||||||
|
|
||||||
REGRESS = nbtree_incomplete_splits
|
REGRESS = nbtree_incomplete_splits
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
-- splits in "incomplete" state
|
-- splits in "incomplete" state
|
||||||
set client_min_messages TO 'warning';
|
set client_min_messages TO 'warning';
|
||||||
create extension if not exists injection_points;
|
create extension if not exists injection_points;
|
||||||
|
create extension if not exists amcheck;
|
||||||
reset client_min_messages;
|
reset client_min_messages;
|
||||||
-- Make all injection points local to this process, for concurrency.
|
-- Make all injection points local to this process, for concurrency.
|
||||||
SELECT injection_points_set_local();
|
SELECT injection_points_set_local();
|
||||||
@@ -87,6 +88,12 @@ begin
|
|||||||
if c <> 200 then
|
if c <> 200 then
|
||||||
raise 'unexpected count % ', c;
|
raise 'unexpected count % ', c;
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
|
-- Also check the index with amcheck. Both to test that the index is
|
||||||
|
-- valid, but also to test that amcheck doesn't wrongly complain
|
||||||
|
-- about incomplete splits.
|
||||||
|
perform bt_index_parent_check('nbtree_incomplete_splits_i_idx'::regclass, true, true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
end;
|
end;
|
||||||
$$;
|
$$;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
-- splits in "incomplete" state
|
-- splits in "incomplete" state
|
||||||
set client_min_messages TO 'warning';
|
set client_min_messages TO 'warning';
|
||||||
create extension if not exists injection_points;
|
create extension if not exists injection_points;
|
||||||
|
create extension if not exists amcheck;
|
||||||
reset client_min_messages;
|
reset client_min_messages;
|
||||||
|
|
||||||
-- Make all injection points local to this process, for concurrency.
|
-- Make all injection points local to this process, for concurrency.
|
||||||
@@ -86,6 +87,12 @@ begin
|
|||||||
if c <> 200 then
|
if c <> 200 then
|
||||||
raise 'unexpected count % ', c;
|
raise 'unexpected count % ', c;
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
|
-- Also check the index with amcheck. Both to test that the index is
|
||||||
|
-- valid, but also to test that amcheck doesn't wrongly complain
|
||||||
|
-- about incomplete splits.
|
||||||
|
perform bt_index_parent_check('nbtree_incomplete_splits_i_idx'::regclass, true, true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
end;
|
end;
|
||||||
$$;
|
$$;
|
||||||
|
|||||||
Reference in New Issue
Block a user