1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-03 09:13:20 +03:00

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:
Tom Lane
2022-09-25 13:10:10 -04:00
parent dda101315a
commit 1d2fec990c
8 changed files with 68 additions and 10 deletions

View File

@@ -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