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

Commitc4fdfb8

Browse files
committed
Fix race condition in parallel regression tests. The new plancache test
was expecting there to be no regular table named 'foo', but it turns outthe rules test transiently creates one, so that plancache would sometimesfail. I couldn't reproduce that in quite a few tries here, but severalbuildfarm machines have shown the failure. Fix by renaming plancache'stemp table to something nonconflicting.
1 parentc9d3b8f commitc4fdfb8

File tree

2 files changed

+26
-22
lines changed

2 files changed

+26
-22
lines changed

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

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
--
22
-- Tests to exercise the plan caching/invalidation mechanism
33
--
4-
CREATE TEMP TABLEfoo AS SELECT * FROM int8_tbl;
4+
CREATE TEMP TABLEpcachetest AS SELECT * FROM int8_tbl;
55
-- create and use a cached plan
6-
PREPARE prepstmt AS SELECT * FROMfoo;
6+
PREPARE prepstmt AS SELECT * FROMpcachetest;
77
EXECUTE prepstmt;
88
q1 | q2
99
------------------+-------------------
@@ -15,7 +15,7 @@ EXECUTE prepstmt;
1515
(5 rows)
1616

1717
-- and one with parameters
18-
PREPARE prepstmt2(bigint) AS SELECT * FROMfoo WHERE q1 = $1;
18+
PREPARE prepstmt2(bigint) AS SELECT * FROMpcachetest WHERE q1 = $1;
1919
EXECUTE prepstmt2(123);
2020
q1 | q2
2121
-----+------------------
@@ -24,14 +24,14 @@ EXECUTE prepstmt2(123);
2424
(2 rows)
2525

2626
-- invalidate the plans and see what happens
27-
DROP TABLEfoo;
27+
DROP TABLEpcachetest;
2828
EXECUTE prepstmt;
29-
ERROR: relation "foo" does not exist
29+
ERROR: relation "pcachetest" does not exist
3030
EXECUTE prepstmt2(123);
31-
ERROR: relation "foo" does not exist
31+
ERROR: relation "pcachetest" does not exist
3232
-- recreate the temp table (this demonstrates that the raw plan is
3333
-- purely textual and doesn't depend on OIDs, for instance)
34-
CREATE TEMP TABLEfoo AS SELECT * FROM int8_tbl ORDER BY 2;
34+
CREATE TEMP TABLEpcachetest AS SELECT * FROM int8_tbl ORDER BY 2;
3535
EXECUTE prepstmt;
3636
q1 | q2
3737
------------------+-------------------
@@ -51,13 +51,13 @@ EXECUTE prepstmt2(123);
5151

5252
-- prepared statements should prevent change in output tupdesc,
5353
-- since clients probably aren't expecting that to change on the fly
54-
ALTER TABLEfoo ADD COLUMN q3 bigint;
54+
ALTER TABLEpcachetest ADD COLUMN q3 bigint;
5555
EXECUTE prepstmt;
5656
ERROR: cached plan must not change result type
5757
EXECUTE prepstmt2(123);
5858
ERROR: cached plan must not change result type
5959
-- but we're nice guys and will let you undo your mistake
60-
ALTER TABLEfoo DROP COLUMN q3;
60+
ALTER TABLEpcachetest DROP COLUMN q3;
6161
EXECUTE prepstmt;
6262
q1 | q2
6363
------------------+-------------------
@@ -77,8 +77,9 @@ EXECUTE prepstmt2(123);
7777

7878
-- Try it with a view, which isn't directly used in the resulting plan
7979
-- but should trigger invalidation anyway
80-
CREATE TEMP VIEW voo AS SELECT * FROM foo;
81-
PREPARE vprep AS SELECT * FROM voo;
80+
CREATE TEMP VIEW pcacheview AS
81+
SELECT * FROM pcachetest;
82+
PREPARE vprep AS SELECT * FROM pcacheview;
8283
EXECUTE vprep;
8384
q1 | q2
8485
------------------+-------------------
@@ -89,7 +90,8 @@ EXECUTE vprep;
8990
4567890123456789 | 4567890123456789
9091
(5 rows)
9192

92-
CREATE OR REPLACE TEMP VIEW voo AS SELECT q1, q2/2 AS q2 FROM foo;
93+
CREATE OR REPLACE TEMP VIEW pcacheview AS
94+
SELECT q1, q2/2 AS q2 FROM pcachetest;
9395
EXECUTE vprep;
9496
q1 | q2
9597
------------------+-------------------

‎src/test/regress/sql/plancache.sql

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,53 +2,55 @@
22
-- Tests to exercise the plan caching/invalidation mechanism
33
--
44

5-
CREATE TEMP TABLEfooASSELECT*FROM int8_tbl;
5+
CREATE TEMP TABLEpcachetestASSELECT*FROM int8_tbl;
66

77
-- create and use a cached plan
8-
PREPARE prepstmtASSELECT*FROMfoo;
8+
PREPARE prepstmtASSELECT*FROMpcachetest;
99

1010
EXECUTE prepstmt;
1111

1212
-- and one with parameters
13-
PREPARE prepstmt2(bigint)ASSELECT*FROMfooWHERE q1= $1;
13+
PREPARE prepstmt2(bigint)ASSELECT*FROMpcachetestWHERE q1= $1;
1414

1515
EXECUTE prepstmt2(123);
1616

1717
-- invalidate the plans and see what happens
18-
DROPTABLEfoo;
18+
DROPTABLEpcachetest;
1919

2020
EXECUTE prepstmt;
2121
EXECUTE prepstmt2(123);
2222

2323
-- recreate the temp table (this demonstrates that the raw plan is
2424
-- purely textual and doesn't depend on OIDs, for instance)
25-
CREATE TEMP TABLEfooASSELECT*FROM int8_tblORDER BY2;
25+
CREATE TEMP TABLEpcachetestASSELECT*FROM int8_tblORDER BY2;
2626

2727
EXECUTE prepstmt;
2828
EXECUTE prepstmt2(123);
2929

3030
-- prepared statements should prevent change in output tupdesc,
3131
-- since clients probably aren't expecting that to change on the fly
32-
ALTERTABLEfoo ADD COLUMN q3bigint;
32+
ALTERTABLEpcachetest ADD COLUMN q3bigint;
3333

3434
EXECUTE prepstmt;
3535
EXECUTE prepstmt2(123);
3636

3737
-- but we're nice guys and will let you undo your mistake
38-
ALTERTABLEfoo DROP COLUMN q3;
38+
ALTERTABLEpcachetest DROP COLUMN q3;
3939

4040
EXECUTE prepstmt;
4141
EXECUTE prepstmt2(123);
4242

4343
-- Try it with a view, which isn't directly used in the resulting plan
4444
-- but should trigger invalidation anyway
45-
CREATE TEMP VIEW vooASSELECT*FROM foo;
45+
CREATE TEMP VIEW pcacheviewAS
46+
SELECT*FROM pcachetest;
4647

47-
PREPARE vprepASSELECT*FROMvoo;
48+
PREPARE vprepASSELECT*FROMpcacheview;
4849

4950
EXECUTE vprep;
5051

51-
CREATEOR REPLACE TEMP VIEW vooASSELECT q1, q2/2AS q2FROM foo;
52+
CREATEOR REPLACE TEMP VIEW pcacheviewAS
53+
SELECT q1, q2/2AS q2FROM pcachetest;
5254

5355
EXECUTE vprep;
5456

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp