Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 2d7d67c

Browse files
committed
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 319a810, so backpatch down to v10. Discussion: https://postgr.es/m/20190807132422.GC15695@paquier.xyz Backpatch-through: 10
1 parent 6754fe6 commit 2d7d67c

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/test/regress/expected/temp.out

+5-4
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ create temp table temp_parted_oncommit_test2
246246
insert into temp_parted_oncommit_test values (1), (2);
247247
commit;
248248
-- no relations remain in this case.
249-
select relname from pg_class where relname like 'temp_parted_oncommit_test%';
249+
select relname from pg_class where relname ~ '^temp_parted_oncommit_test';
250250
relname
251251
---------
252252
(0 rows)
@@ -273,7 +273,8 @@ select * from temp_parted_oncommit_test;
273273
(1 row)
274274

275275
-- two relations remain in this case.
276-
select relname from pg_class where relname like 'temp_parted_oncommit_test%';
276+
select relname from pg_class where relname ~ '^temp_parted_oncommit_test'
277+
order by relname;
277278
relname
278279
----------------------------
279280
temp_parted_oncommit_test
@@ -290,7 +291,7 @@ create temp table temp_inh_oncommit_test1 ()
290291
insert into temp_inh_oncommit_test1 values (1);
291292
commit;
292293
-- no relations remain in this case
293-
select relname from pg_class where relname like 'temp_inh_oncommit_test%';
294+
select relname from pg_class where relname ~ '^temp_inh_oncommit_test';
294295
relname
295296
---------
296297
(0 rows)
@@ -309,7 +310,7 @@ select * from temp_inh_oncommit_test;
309310
(0 rows)
310311

311312
-- one relation remains
312-
select relname from pg_class where relname like 'temp_inh_oncommit_test%';
313+
select relname from pg_class where relname ~ '^temp_inh_oncommit_test';
313314
relname
314315
------------------------
315316
temp_inh_oncommit_test

src/test/regress/sql/temp.sql

+5-4
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ create temp table temp_parted_oncommit_test2
192192
insert into temp_parted_oncommit_test values (1), (2);
193193
commit;
194194
-- no relations remain in this case.
195-
select relname from pg_class where relname like 'temp_parted_oncommit_test%';
195+
select relname from pg_class where relname ~ '^temp_parted_oncommit_test';
196196
-- Using ON COMMIT DELETE on a partitioned table does not remove
197197
-- all rows if partitions preserve their data.
198198
begin;
@@ -210,7 +210,8 @@ commit;
210210
-- preserved.
211211
select * from temp_parted_oncommit_test;
212212
-- two relations remain in this case.
213-
select relname from pg_class where relname like 'temp_parted_oncommit_test%';
213+
select relname from pg_class where relname ~ '^temp_parted_oncommit_test'
214+
order by relname;
214215
drop table temp_parted_oncommit_test;
215216

216217
-- Check dependencies between ON COMMIT actions with inheritance trees.
@@ -222,7 +223,7 @@ create temp table temp_inh_oncommit_test1 ()
222223
insert into temp_inh_oncommit_test1 values (1);
223224
commit;
224225
-- no relations remain in this case
225-
select relname from pg_class where relname like 'temp_inh_oncommit_test%';
226+
select relname from pg_class where relname ~ '^temp_inh_oncommit_test';
226227
-- Data on the parent is removed, and the child goes away.
227228
begin;
228229
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);
233234
commit;
234235
select * from temp_inh_oncommit_test;
235236
-- one relation remains
236-
select relname from pg_class where relname like 'temp_inh_oncommit_test%';
237+
select relname from pg_class where relname ~ '^temp_inh_oncommit_test';
237238
drop table temp_inh_oncommit_test;
238239

239240
-- Tests with two-phase commit

0 commit comments

Comments
 (0)