aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2022-09-25 13:10:10 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2022-09-25 13:10:17 -0400
commit1d2fec990c4dd6da8ffe5ca6b3c2aed2553197fb (patch)
treefea2286da6909ddcc0e77a0033c36749bef4f09c /src
parentdda101315ad93e9b39c48eeb53b131d171d1fd0b (diff)
downloadpostgresql-1d2fec990c4dd6da8ffe5ca6b3c2aed2553197fb.tar.gz
postgresql-1d2fec990c4dd6da8ffe5ca6b3c2aed2553197fb.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/test/regress/expected/brin.out7
-rw-r--r--src/test/regress/expected/gin.out11
-rw-r--r--src/test/regress/expected/gist.out8
-rw-r--r--src/test/regress/expected/spgist.out11
-rw-r--r--src/test/regress/sql/brin.sql8
-rw-r--r--src/test/regress/sql/gin.sql12
-rw-r--r--src/test/regress/sql/gist.sql9
-rw-r--r--src/test/regress/sql/spgist.sql12
8 files changed, 68 insertions, 10 deletions
diff --git a/src/test/regress/expected/brin.out b/src/test/regress/expected/brin.out
index ae4c424e79f..73fa38396e4 100644
--- a/src/test/regress/expected/brin.out
+++ b/src/test/regress/expected/brin.out
@@ -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;
diff --git a/src/test/regress/expected/gin.out b/src/test/regress/expected/gin.out
index 1a0c3c6167f..0af464309ee 100644
--- a/src/test/regress/expected/gin.out
+++ b/src/test/regress/expected/gin.out
@@ -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;
diff --git a/src/test/regress/expected/gist.out b/src/test/regress/expected/gist.out
index 822000cca70..c75bbb23b6e 100644
--- a/src/test/regress/expected/gist.out
+++ b/src/test/regress/expected/gist.out
@@ -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),
@@ -395,3 +395,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;
diff --git a/src/test/regress/expected/spgist.out b/src/test/regress/expected/spgist.out
index f07b6f0145e..2e911285600 100644
--- a/src/test/regress/expected/spgist.out
+++ b/src/test/regress/expected/spgist.out
@@ -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
diff --git a/src/test/regress/sql/brin.sql b/src/test/regress/sql/brin.sql
index 33a30fcf777..e68e9e18df5 100644
--- a/src/test/regress/sql/brin.sql
+++ b/src/test/regress/sql/brin.sql
@@ -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;
diff --git a/src/test/regress/sql/gin.sql b/src/test/regress/sql/gin.sql
index 746880937bb..0c6905ba3bb 100644
--- a/src/test/regress/sql/gin.sql
+++ b/src/test/regress/sql/gin.sql
@@ -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;
diff --git a/src/test/regress/sql/gist.sql b/src/test/regress/sql/gist.sql
index 77a51bd6b39..6f1fc65f128 100644
--- a/src/test/regress/sql/gist.sql
+++ b/src/test/regress/sql/gist.sql
@@ -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)),
@@ -179,3 +179,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;
diff --git a/src/test/regress/sql/spgist.sql b/src/test/regress/sql/spgist.sql
index d56b80a51b6..4828ede68c3 100644
--- a/src/test/regress/sql/spgist.sql
+++ b/src/test/regress/sql/spgist.sql
@@ -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