Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1d2fec9

Browse files
committed
Avoid loss of code coverage with unlogged-index test cases.
Commit4fb5c79 intended to add coverage of some ambuildemptymethods that were not getting reached, without removing anytest coverage. However, by changing a temp table to unloggedit managed to negate the intent of4c51a2d, which means thatwe didn't have reliable test coverage of ginvacuum.c anymore.As things stand, much of that file might or might not get reacheddepending on timing, which seems pretty undesirable.Although this is only clearly broken for the GIN test, it seemsbest to revert4fb5c79 altogether and instead add bespoke testcases covering unlogged indexes for these four AMs. We don'tneed 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 undodec8ad3. Since the testing deficiency that thathacked around was later fixed by2f2e24d, let's intentionally leavean unlogged table behind to improve test coverage in the modules thatuse the regression database for other test purposes. (The case I usedalso leaves an unlogged sequence behind.)Per report from Alex Kozhemyakin. Back-patch to v15 where thefaulty test came in.Discussion:https://postgr.es/m/b00c8ee096ee46cd25c183125562a1a7@postgrespro.ru
1 parentdda1013 commit1d2fec9

File tree

8 files changed

+68
-10
lines changed

8 files changed

+68
-10
lines changed

‎src/test/regress/expected/brin.out

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ ERROR: block number out of range: -1
484484
SELECT brin_summarize_range('brin_summarize_idx', 4294967296);
485485
ERROR: block number out of range: 4294967296
486486
-- test value merging in add_value
487-
CREATEUNLOGGEDTABLE brintest_2 (n numrange);
487+
CREATE TABLE brintest_2 (n numrange);
488488
CREATE INDEX brinidx_2 ON brintest_2 USING brin (n);
489489
INSERT INTO brintest_2 VALUES ('empty');
490490
INSERT INTO brintest_2 VALUES (numrange(0, 2^1000::numeric));
@@ -567,3 +567,8 @@ SELECT * FROM brintest_3 WHERE b < '0';
567567

568568
DROP TABLE brintest_3;
569569
RESET enable_seqscan;
570+
-- test an unlogged table, mostly to get coverage of brinbuildempty
571+
CREATE UNLOGGED TABLE brintest_unlogged (n numrange);
572+
CREATE INDEX brinidx_unlogged ON brintest_unlogged USING brin (n);
573+
INSERT INTO brintest_unlogged VALUES (numrange(0, 2^1000::numeric));
574+
DROP TABLE brintest_unlogged;

‎src/test/regress/expected/gin.out

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ select count(*) > 0 as ok from gin_test_tbl where i @> array[1];
7474

7575
reset gin_fuzzy_search_limit;
7676
-- Test optimization of empty queries
77-
createunlogged table t_gin_test_tbl(i int4[], j int4[]);
77+
createtemp table t_gin_test_tbl(i int4[], j int4[]);
7878
create index on t_gin_test_tbl using gin (i, j);
7979
insert into t_gin_test_tbl
8080
values
@@ -288,3 +288,12 @@ select count(*) from t_gin_test_tbl where j @> '{}'::int[];
288288
reset enable_seqscan;
289289
reset enable_bitmapscan;
290290
drop table t_gin_test_tbl;
291+
-- test an unlogged table, mostly to get coverage of ginbuildempty
292+
create unlogged table t_gin_test_tbl(i int4[], j int4[]);
293+
create index on t_gin_test_tbl using gin (i, j);
294+
insert into t_gin_test_tbl
295+
values
296+
(null, null),
297+
('{}', null),
298+
('{1}', '{2,3}');
299+
drop table t_gin_test_tbl;

‎src/test/regress/expected/gist.out

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ reindex index gist_pointidx;
3636
--
3737
-- Test Index-only plans on GiST indexes
3838
--
39-
createunloggedtable gist_tbl (b box, p point, c circle);
39+
create table gist_tbl (b box, p point, c circle);
4040
insert into gist_tbl
4141
select box(point(0.05*i, 0.05*i), point(0.05*i, 0.05*i)),
4242
point(0.05*i, 0.05*i),
@@ -395,3 +395,9 @@ reset enable_seqscan;
395395
reset enable_bitmapscan;
396396
reset enable_indexonlyscan;
397397
drop table gist_tbl;
398+
-- test an unlogged table, mostly to get coverage of gistbuildempty
399+
create unlogged table gist_tbl (b box);
400+
create index gist_tbl_box_index on gist_tbl using gist (b);
401+
insert into gist_tbl
402+
select box(point(0.05*i, 0.05*i)) from generate_series(0,10) as i;
403+
drop table gist_tbl;

‎src/test/regress/expected/spgist.out

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ vacuum spgist_point_tbl;
2626
-- Test rescan paths (cf. bug #15378)
2727
-- use box and && rather than point, so that rescan happens when the
2828
-- traverse stack is non-empty
29-
createunloggedtable spgist_box_tbl(id serial, b box);
29+
create table spgist_box_tbl(id serial, b box);
3030
insert into spgist_box_tbl(b)
3131
select box(point(i,j),point(i+s,j+s))
3232
from generate_series(1,100,5) i,
@@ -41,7 +41,6 @@ select count(*)
4141
3
4242
(1 row)
4343

44-
drop table spgist_box_tbl;
4544
-- The point opclass's choose method only uses the spgMatchNode action,
4645
-- so the other actions are not tested by the above. Create an index using
4746
-- text opclass, which uses the others actions.
@@ -87,3 +86,11 @@ select * from spgist_domain_tbl where f1 = 'fo';
8786
fo
8887
(1 row)
8988

89+
-- test an unlogged table, mostly to get coverage of spgistbuildempty
90+
create unlogged table spgist_unlogged_tbl(id serial, b box);
91+
create index spgist_unlogged_idx on spgist_unlogged_tbl using spgist (b);
92+
insert into spgist_unlogged_tbl(b)
93+
select box(point(i,j))
94+
from generate_series(1,100,5) i,
95+
generate_series(1,10,5) j;
96+
-- leave this table around, to help in testing dump/restore

‎src/test/regress/sql/brin.sql

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ SELECT brin_summarize_range('brin_summarize_idx', -1);
449449
SELECT brin_summarize_range('brin_summarize_idx',4294967296);
450450

451451
-- test value merging in add_value
452-
CREATEUNLOGGEDTABLE brintest_2 (n numrange);
452+
CREATETABLEbrintest_2 (n numrange);
453453
CREATEINDEXbrinidx_2ON brintest_2 USING brin (n);
454454
INSERT INTO brintest_2VALUES ('empty');
455455
INSERT INTO brintest_2VALUES (numrange(0,2^1000::numeric));
@@ -509,3 +509,9 @@ SELECT * FROM brintest_3 WHERE b < '0';
509509

510510
DROPTABLE brintest_3;
511511
RESET enable_seqscan;
512+
513+
-- test an unlogged table, mostly to get coverage of brinbuildempty
514+
CREATE UNLOGGED TABLE brintest_unlogged (n numrange);
515+
CREATEINDEXbrinidx_unloggedON brintest_unlogged USING brin (n);
516+
INSERT INTO brintest_unloggedVALUES (numrange(0,2^1000::numeric));
517+
DROPTABLE brintest_unlogged;

‎src/test/regress/sql/gin.sql

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ select count(*) > 0 as ok from gin_test_tbl where i @> array[1];
5252
reset gin_fuzzy_search_limit;
5353

5454
-- Test optimization of empty queries
55-
createunlogged table t_gin_test_tbl(i int4[], j int4[]);
55+
createtemp table t_gin_test_tbl(i int4[], j int4[]);
5656
createindexon t_gin_test_tbl using gin (i, j);
5757
insert into t_gin_test_tbl
5858
values
@@ -171,3 +171,13 @@ reset enable_seqscan;
171171
reset enable_bitmapscan;
172172

173173
droptable t_gin_test_tbl;
174+
175+
-- test an unlogged table, mostly to get coverage of ginbuildempty
176+
create unlogged table t_gin_test_tbl(i int4[], j int4[]);
177+
createindexon t_gin_test_tbl using gin (i, j);
178+
insert into t_gin_test_tbl
179+
values
180+
(null,null),
181+
('{}',null),
182+
('{1}','{2,3}');
183+
droptable t_gin_test_tbl;

‎src/test/regress/sql/gist.sql

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ reindex index gist_pointidx;
4141
-- Test Index-only plans on GiST indexes
4242
--
4343

44-
createunloggedtable gist_tbl (bbox, ppoint, ccircle);
44+
createtablegist_tbl (bbox, ppoint, ccircle);
4545

4646
insert into gist_tbl
4747
selectbox(point(0.05*i,0.05*i),point(0.05*i,0.05*i)),
@@ -179,3 +179,10 @@ reset enable_bitmapscan;
179179
reset enable_indexonlyscan;
180180

181181
droptable gist_tbl;
182+
183+
-- test an unlogged table, mostly to get coverage of gistbuildempty
184+
create unlogged table gist_tbl (bbox);
185+
createindexgist_tbl_box_indexon gist_tbl using gist (b);
186+
insert into gist_tbl
187+
selectbox(point(0.05*i,0.05*i))from generate_series(0,10)as i;
188+
droptable gist_tbl;

‎src/test/regress/sql/spgist.sql

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ vacuum spgist_point_tbl;
3434
-- use box and && rather than point, so that rescan happens when the
3535
-- traverse stack is non-empty
3636

37-
createunloggedtable spgist_box_tbl(idserial, bbox);
37+
createtablespgist_box_tbl(idserial, bbox);
3838
insert into spgist_box_tbl(b)
3939
selectbox(point(i,j),point(i+s,j+s))
4040
from generate_series(1,100,5) i,
@@ -45,7 +45,6 @@ create index spgist_box_idx on spgist_box_tbl using spgist (b);
4545
selectcount(*)
4646
from (values (point(5,5)),(point(8,8)),(point(12,12))) v(p)
4747
where exists(select*from spgist_box_tbl bwhereb.b &&box(v.p,v.p));
48-
droptable spgist_box_tbl;
4948

5049
-- The point opclass's choose method only uses the spgMatchNode action,
5150
-- 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');
8180
explain (costs off)
8281
select*from spgist_domain_tblwhere f1='fo';
8382
select*from spgist_domain_tblwhere f1='fo';
83+
84+
-- test an unlogged table, mostly to get coverage of spgistbuildempty
85+
create unlogged table spgist_unlogged_tbl(idserial, bbox);
86+
createindexspgist_unlogged_idxon spgist_unlogged_tbl using spgist (b);
87+
insert into spgist_unlogged_tbl(b)
88+
selectbox(point(i,j))
89+
from generate_series(1,100,5) i,
90+
generate_series(1,10,5) j;
91+
-- leave this table around, to help in testing dump/restore

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp