Avoid loss of code coverage with unlogged-index test cases.
Commit 4fb5c794e intended to add coverage of some ambuildempty methods that were not getting reached, without removing any test coverage. However, by changing a temp table to unlogged it managed to negate the intent of 4c51a2d1e, which means that we didn't have reliable test coverage of ginvacuum.c anymore. As things stand, much of that file might or might not get reached depending on timing, which seems pretty undesirable. Although this is only clearly broken for the GIN test, it seems best to revert 4fb5c794e altogether and instead add bespoke test cases covering unlogged indexes for these four AMs. We don't need to do very much with them, so the extra tests are cheap. (Note that btree, hash, and bloom already have similar test cases, so they need no additional work.) We can also undo dec8ad367. Since the testing deficiency that that hacked around was later fixed by 2f2e24d90, let's intentionally leave an unlogged table behind to improve test coverage in the modules that use the regression database for other test purposes. (The case I used also leaves an unlogged sequence behind.) Per report from Alex Kozhemyakin. Back-patch to v15 where the faulty test came in. Discussion: https://postgr.es/m/b00c8ee096ee46cd25c183125562a1a7@postgrespro.ru
This commit is contained in:
parent
7a41e34e68
commit
7a84c35fe6
@ -484,7 +484,7 @@ ERROR: block number out of range: -1
|
||||
SELECT brin_summarize_range('brin_summarize_idx', 4294967296);
|
||||
ERROR: block number out of range: 4294967296
|
||||
-- test value merging in add_value
|
||||
CREATE UNLOGGED TABLE brintest_2 (n numrange);
|
||||
CREATE TABLE brintest_2 (n numrange);
|
||||
CREATE INDEX brinidx_2 ON brintest_2 USING brin (n);
|
||||
INSERT INTO brintest_2 VALUES ('empty');
|
||||
INSERT INTO brintest_2 VALUES (numrange(0, 2^1000::numeric));
|
||||
@ -567,3 +567,8 @@ SELECT * FROM brintest_3 WHERE b < '0';
|
||||
|
||||
DROP TABLE brintest_3;
|
||||
RESET enable_seqscan;
|
||||
-- test an unlogged table, mostly to get coverage of brinbuildempty
|
||||
CREATE UNLOGGED TABLE brintest_unlogged (n numrange);
|
||||
CREATE INDEX brinidx_unlogged ON brintest_unlogged USING brin (n);
|
||||
INSERT INTO brintest_unlogged VALUES (numrange(0, 2^1000::numeric));
|
||||
DROP TABLE brintest_unlogged;
|
||||
|
@ -74,7 +74,7 @@ select count(*) > 0 as ok from gin_test_tbl where i @> array[1];
|
||||
|
||||
reset gin_fuzzy_search_limit;
|
||||
-- Test optimization of empty queries
|
||||
create unlogged table t_gin_test_tbl(i int4[], j int4[]);
|
||||
create temp table t_gin_test_tbl(i int4[], j int4[]);
|
||||
create index on t_gin_test_tbl using gin (i, j);
|
||||
insert into t_gin_test_tbl
|
||||
values
|
||||
@ -288,3 +288,12 @@ select count(*) from t_gin_test_tbl where j @> '{}'::int[];
|
||||
reset enable_seqscan;
|
||||
reset enable_bitmapscan;
|
||||
drop table t_gin_test_tbl;
|
||||
-- test an unlogged table, mostly to get coverage of ginbuildempty
|
||||
create unlogged table t_gin_test_tbl(i int4[], j int4[]);
|
||||
create index on t_gin_test_tbl using gin (i, j);
|
||||
insert into t_gin_test_tbl
|
||||
values
|
||||
(null, null),
|
||||
('{}', null),
|
||||
('{1}', '{2,3}');
|
||||
drop table t_gin_test_tbl;
|
||||
|
@ -36,7 +36,7 @@ reindex index gist_pointidx;
|
||||
--
|
||||
-- Test Index-only plans on GiST indexes
|
||||
--
|
||||
create unlogged table gist_tbl (b box, p point, c circle);
|
||||
create table gist_tbl (b box, p point, c circle);
|
||||
insert into gist_tbl
|
||||
select box(point(0.05*i, 0.05*i), point(0.05*i, 0.05*i)),
|
||||
point(0.05*i, 0.05*i),
|
||||
@ -392,3 +392,9 @@ reset enable_seqscan;
|
||||
reset enable_bitmapscan;
|
||||
reset enable_indexonlyscan;
|
||||
drop table gist_tbl;
|
||||
-- test an unlogged table, mostly to get coverage of gistbuildempty
|
||||
create unlogged table gist_tbl (b box);
|
||||
create index gist_tbl_box_index on gist_tbl using gist (b);
|
||||
insert into gist_tbl
|
||||
select box(point(0.05*i, 0.05*i)) from generate_series(0,10) as i;
|
||||
drop table gist_tbl;
|
||||
|
@ -26,7 +26,7 @@ vacuum spgist_point_tbl;
|
||||
-- Test rescan paths (cf. bug #15378)
|
||||
-- use box and && rather than point, so that rescan happens when the
|
||||
-- traverse stack is non-empty
|
||||
create unlogged table spgist_box_tbl(id serial, b box);
|
||||
create table spgist_box_tbl(id serial, b box);
|
||||
insert into spgist_box_tbl(b)
|
||||
select box(point(i,j),point(i+s,j+s))
|
||||
from generate_series(1,100,5) i,
|
||||
@ -41,7 +41,6 @@ select count(*)
|
||||
3
|
||||
(1 row)
|
||||
|
||||
drop table spgist_box_tbl;
|
||||
-- The point opclass's choose method only uses the spgMatchNode action,
|
||||
-- so the other actions are not tested by the above. Create an index using
|
||||
-- text opclass, which uses the others actions.
|
||||
@ -87,3 +86,11 @@ select * from spgist_domain_tbl where f1 = 'fo';
|
||||
fo
|
||||
(1 row)
|
||||
|
||||
-- test an unlogged table, mostly to get coverage of spgistbuildempty
|
||||
create unlogged table spgist_unlogged_tbl(id serial, b box);
|
||||
create index spgist_unlogged_idx on spgist_unlogged_tbl using spgist (b);
|
||||
insert into spgist_unlogged_tbl(b)
|
||||
select box(point(i,j))
|
||||
from generate_series(1,100,5) i,
|
||||
generate_series(1,10,5) j;
|
||||
-- leave this table around, to help in testing dump/restore
|
||||
|
@ -449,7 +449,7 @@ SELECT brin_summarize_range('brin_summarize_idx', -1);
|
||||
SELECT brin_summarize_range('brin_summarize_idx', 4294967296);
|
||||
|
||||
-- test value merging in add_value
|
||||
CREATE UNLOGGED TABLE brintest_2 (n numrange);
|
||||
CREATE TABLE brintest_2 (n numrange);
|
||||
CREATE INDEX brinidx_2 ON brintest_2 USING brin (n);
|
||||
INSERT INTO brintest_2 VALUES ('empty');
|
||||
INSERT INTO brintest_2 VALUES (numrange(0, 2^1000::numeric));
|
||||
@ -509,3 +509,9 @@ SELECT * FROM brintest_3 WHERE b < '0';
|
||||
|
||||
DROP TABLE brintest_3;
|
||||
RESET enable_seqscan;
|
||||
|
||||
-- test an unlogged table, mostly to get coverage of brinbuildempty
|
||||
CREATE UNLOGGED TABLE brintest_unlogged (n numrange);
|
||||
CREATE INDEX brinidx_unlogged ON brintest_unlogged USING brin (n);
|
||||
INSERT INTO brintest_unlogged VALUES (numrange(0, 2^1000::numeric));
|
||||
DROP TABLE brintest_unlogged;
|
||||
|
@ -52,7 +52,7 @@ select count(*) > 0 as ok from gin_test_tbl where i @> array[1];
|
||||
reset gin_fuzzy_search_limit;
|
||||
|
||||
-- Test optimization of empty queries
|
||||
create unlogged table t_gin_test_tbl(i int4[], j int4[]);
|
||||
create temp table t_gin_test_tbl(i int4[], j int4[]);
|
||||
create index on t_gin_test_tbl using gin (i, j);
|
||||
insert into t_gin_test_tbl
|
||||
values
|
||||
@ -171,3 +171,13 @@ reset enable_seqscan;
|
||||
reset enable_bitmapscan;
|
||||
|
||||
drop table t_gin_test_tbl;
|
||||
|
||||
-- test an unlogged table, mostly to get coverage of ginbuildempty
|
||||
create unlogged table t_gin_test_tbl(i int4[], j int4[]);
|
||||
create index on t_gin_test_tbl using gin (i, j);
|
||||
insert into t_gin_test_tbl
|
||||
values
|
||||
(null, null),
|
||||
('{}', null),
|
||||
('{1}', '{2,3}');
|
||||
drop table t_gin_test_tbl;
|
||||
|
@ -41,7 +41,7 @@ reindex index gist_pointidx;
|
||||
-- Test Index-only plans on GiST indexes
|
||||
--
|
||||
|
||||
create unlogged table gist_tbl (b box, p point, c circle);
|
||||
create table gist_tbl (b box, p point, c circle);
|
||||
|
||||
insert into gist_tbl
|
||||
select box(point(0.05*i, 0.05*i), point(0.05*i, 0.05*i)),
|
||||
@ -175,3 +175,10 @@ reset enable_bitmapscan;
|
||||
reset enable_indexonlyscan;
|
||||
|
||||
drop table gist_tbl;
|
||||
|
||||
-- test an unlogged table, mostly to get coverage of gistbuildempty
|
||||
create unlogged table gist_tbl (b box);
|
||||
create index gist_tbl_box_index on gist_tbl using gist (b);
|
||||
insert into gist_tbl
|
||||
select box(point(0.05*i, 0.05*i)) from generate_series(0,10) as i;
|
||||
drop table gist_tbl;
|
||||
|
@ -34,7 +34,7 @@ vacuum spgist_point_tbl;
|
||||
-- use box and && rather than point, so that rescan happens when the
|
||||
-- traverse stack is non-empty
|
||||
|
||||
create unlogged table spgist_box_tbl(id serial, b box);
|
||||
create table spgist_box_tbl(id serial, b box);
|
||||
insert into spgist_box_tbl(b)
|
||||
select box(point(i,j),point(i+s,j+s))
|
||||
from generate_series(1,100,5) i,
|
||||
@ -45,7 +45,6 @@ create index spgist_box_idx on spgist_box_tbl using spgist (b);
|
||||
select count(*)
|
||||
from (values (point(5,5)),(point(8,8)),(point(12,12))) v(p)
|
||||
where exists(select * from spgist_box_tbl b where b.b && box(v.p,v.p));
|
||||
drop table spgist_box_tbl;
|
||||
|
||||
-- The point opclass's choose method only uses the spgMatchNode action,
|
||||
-- so the other actions are not tested by the above. Create an index using
|
||||
@ -81,3 +80,12 @@ insert into spgist_domain_tbl values('fee'), ('fi'), ('fo'), ('fum');
|
||||
explain (costs off)
|
||||
select * from spgist_domain_tbl where f1 = 'fo';
|
||||
select * from spgist_domain_tbl where f1 = 'fo';
|
||||
|
||||
-- test an unlogged table, mostly to get coverage of spgistbuildempty
|
||||
create unlogged table spgist_unlogged_tbl(id serial, b box);
|
||||
create index spgist_unlogged_idx on spgist_unlogged_tbl using spgist (b);
|
||||
insert into spgist_unlogged_tbl(b)
|
||||
select box(point(i,j))
|
||||
from generate_series(1,100,5) i,
|
||||
generate_series(1,10,5) j;
|
||||
-- leave this table around, to help in testing dump/restore
|
||||
|
Loading…
x
Reference in New Issue
Block a user