Commit 2d7d67cc authored by Michael Paquier's avatar Michael Paquier

Fix random regression failure in test case "temp"

This test case could fail because of an incorrect result ordering when
looking up at pg_class entries.  This commit adds an ORDER BY to the
culprit query.  The cause of the failure was likely caused by a plan
switch.  By default, the planner would likely choose an index-only scan
or an index scan, but even a small change in the startup cost could have
caused a bitmap heap scan to be chosen, causing the failure.

While on it, switch some filtering quals to a regular expression as per
an idea of Tom Lane.  As previously shaped, the quals would have
selected any relations whose name begins with "temp".  And that could
cause failures if another test running in parallel began to use similar
relation names.

Per report from buildfarm member anole, though the failure was very
rare.  This test has been introduced by 319a8101, so backpatch down to
v10.

Discussion: https://postgr.es/m/20190807132422.GC15695@paquier.xyz
Backpatch-through: 10
parent 6754fe65
......@@ -246,7 +246,7 @@ create temp table temp_parted_oncommit_test2
insert into temp_parted_oncommit_test values (1), (2);
commit;
-- no relations remain in this case.
select relname from pg_class where relname like 'temp_parted_oncommit_test%';
select relname from pg_class where relname ~ '^temp_parted_oncommit_test';
relname
---------
(0 rows)
......@@ -273,7 +273,8 @@ select * from temp_parted_oncommit_test;
(1 row)
-- two relations remain in this case.
select relname from pg_class where relname like 'temp_parted_oncommit_test%';
select relname from pg_class where relname ~ '^temp_parted_oncommit_test'
order by relname;
relname
----------------------------
temp_parted_oncommit_test
......@@ -290,7 +291,7 @@ create temp table temp_inh_oncommit_test1 ()
insert into temp_inh_oncommit_test1 values (1);
commit;
-- no relations remain in this case
select relname from pg_class where relname like 'temp_inh_oncommit_test%';
select relname from pg_class where relname ~ '^temp_inh_oncommit_test';
relname
---------
(0 rows)
......@@ -309,7 +310,7 @@ select * from temp_inh_oncommit_test;
(0 rows)
-- one relation remains
select relname from pg_class where relname like 'temp_inh_oncommit_test%';
select relname from pg_class where relname ~ '^temp_inh_oncommit_test';
relname
------------------------
temp_inh_oncommit_test
......
......@@ -192,7 +192,7 @@ create temp table temp_parted_oncommit_test2
insert into temp_parted_oncommit_test values (1), (2);
commit;
-- no relations remain in this case.
select relname from pg_class where relname like 'temp_parted_oncommit_test%';
select relname from pg_class where relname ~ '^temp_parted_oncommit_test';
-- Using ON COMMIT DELETE on a partitioned table does not remove
-- all rows if partitions preserve their data.
begin;
......@@ -210,7 +210,8 @@ commit;
-- preserved.
select * from temp_parted_oncommit_test;
-- two relations remain in this case.
select relname from pg_class where relname like 'temp_parted_oncommit_test%';
select relname from pg_class where relname ~ '^temp_parted_oncommit_test'
order by relname;
drop table temp_parted_oncommit_test;
-- Check dependencies between ON COMMIT actions with inheritance trees.
......@@ -222,7 +223,7 @@ create temp table temp_inh_oncommit_test1 ()
insert into temp_inh_oncommit_test1 values (1);
commit;
-- no relations remain in this case
select relname from pg_class where relname like 'temp_inh_oncommit_test%';
select relname from pg_class where relname ~ '^temp_inh_oncommit_test';
-- Data on the parent is removed, and the child goes away.
begin;
create temp table temp_inh_oncommit_test (a int) on commit delete rows;
......@@ -233,7 +234,7 @@ insert into temp_inh_oncommit_test values (1);
commit;
select * from temp_inh_oncommit_test;
-- one relation remains
select relname from pg_class where relname like 'temp_inh_oncommit_test%';
select relname from pg_class where relname ~ '^temp_inh_oncommit_test';
drop table temp_inh_oncommit_test;
-- Tests with two-phase commit
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment