From 89f5eb26f6b9b2739aacf53676bfa0eee7be421a Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Fri, 19 May 2023 10:57:46 -0400 Subject: [PATCH] Avoid naming conflict between transactions.sql and namespace.sql. Commits 681d9e462 et al added a test case in namespace.sql that implicitly relied on there not being a table "public.abc". However, the concurrently-run transactions.sql test creates precisely such a table, so with the right timing you'd get a failure. Creating a table named as generically as "abc" in a common schema seems like bad practice, so fix this by changing the name of transactions.sql's table. (Compare 2cf8c7aa4.) Marina Polyakova Discussion: https://postgr.es/m/80d0201636665d82185942e7112257b4@postgrespro.ru --- src/test/regress/expected/transactions.out | 76 +++++++++++----------- src/test/regress/sql/transactions.sql | 64 +++++++++--------- 2 files changed, 70 insertions(+), 70 deletions(-) diff --git a/src/test/regress/expected/transactions.out b/src/test/regress/expected/transactions.out index a46fa5d48a..4e45506877 100644 --- a/src/test/regress/expected/transactions.out +++ b/src/test/regress/expected/transactions.out @@ -575,10 +575,10 @@ drop function inverse(int); -- performed in the aborted subtransaction begin; savepoint x; -create table abc (a int); -insert into abc values (5); -insert into abc values (10); -declare foo cursor for select * from abc; +create table trans_abc (a int); +insert into trans_abc values (5); +insert into trans_abc values (10); +declare foo cursor for select * from trans_abc; fetch from foo; a --- @@ -591,11 +591,11 @@ fetch from foo; ERROR: cursor "foo" does not exist commit; begin; -create table abc (a int); -insert into abc values (5); -insert into abc values (10); -insert into abc values (15); -declare foo cursor for select * from abc; +create table trans_abc (a int); +insert into trans_abc values (5); +insert into trans_abc values (10); +insert into trans_abc values (15); +declare foo cursor for select * from trans_abc; fetch from foo; a --- @@ -664,7 +664,7 @@ COMMIT; DROP FUNCTION create_temp_tab(); DROP FUNCTION invert(x float8); -- Tests for AND CHAIN -CREATE TABLE abc (a int); +CREATE TABLE trans_abc (a int); -- set nondefault value so we have something to override below SET default_transaction_read_only = on; START TRANSACTION ISOLATION LEVEL REPEATABLE READ, READ WRITE, DEFERRABLE; @@ -686,8 +686,8 @@ SHOW transaction_deferrable; on (1 row) -INSERT INTO abc VALUES (1); -INSERT INTO abc VALUES (2); +INSERT INTO trans_abc VALUES (1); +INSERT INTO trans_abc VALUES (2); COMMIT AND CHAIN; -- TBLOCK_END SHOW transaction_isolation; transaction_isolation @@ -707,11 +707,11 @@ SHOW transaction_deferrable; on (1 row) -INSERT INTO abc VALUES ('error'); +INSERT INTO trans_abc VALUES ('error'); ERROR: invalid input syntax for type integer: "error" -LINE 1: INSERT INTO abc VALUES ('error'); - ^ -INSERT INTO abc VALUES (3); -- check it's really aborted +LINE 1: INSERT INTO trans_abc VALUES ('error'); + ^ +INSERT INTO trans_abc VALUES (3); -- check it's really aborted ERROR: current transaction is aborted, commands ignored until end of transaction block COMMIT AND CHAIN; -- TBLOCK_ABORT_END SHOW transaction_isolation; @@ -732,7 +732,7 @@ SHOW transaction_deferrable; on (1 row) -INSERT INTO abc VALUES (4); +INSERT INTO trans_abc VALUES (4); COMMIT; START TRANSACTION ISOLATION LEVEL REPEATABLE READ, READ WRITE, DEFERRABLE; SHOW transaction_isolation; @@ -754,10 +754,10 @@ SHOW transaction_deferrable; (1 row) SAVEPOINT x; -INSERT INTO abc VALUES ('error'); +INSERT INTO trans_abc VALUES ('error'); ERROR: invalid input syntax for type integer: "error" -LINE 1: INSERT INTO abc VALUES ('error'); - ^ +LINE 1: INSERT INTO trans_abc VALUES ('error'); + ^ COMMIT AND CHAIN; -- TBLOCK_ABORT_PENDING SHOW transaction_isolation; transaction_isolation @@ -777,7 +777,7 @@ SHOW transaction_deferrable; on (1 row) -INSERT INTO abc VALUES (5); +INSERT INTO trans_abc VALUES (5); COMMIT; START TRANSACTION ISOLATION LEVEL REPEATABLE READ, READ WRITE, DEFERRABLE; SHOW transaction_isolation; @@ -839,7 +839,7 @@ SHOW transaction_deferrable; off (1 row) -INSERT INTO abc VALUES (6); +INSERT INTO trans_abc VALUES (6); ROLLBACK AND CHAIN; -- TBLOCK_ABORT_PENDING SHOW transaction_isolation; transaction_isolation @@ -859,10 +859,10 @@ SHOW transaction_deferrable; off (1 row) -INSERT INTO abc VALUES ('error'); +INSERT INTO trans_abc VALUES ('error'); ERROR: invalid input syntax for type integer: "error" -LINE 1: INSERT INTO abc VALUES ('error'); - ^ +LINE 1: INSERT INTO trans_abc VALUES ('error'); + ^ ROLLBACK AND CHAIN; -- TBLOCK_ABORT_END SHOW transaction_isolation; transaction_isolation @@ -888,7 +888,7 @@ COMMIT AND CHAIN; -- error ERROR: COMMIT AND CHAIN can only be used in transaction blocks ROLLBACK AND CHAIN; -- error ERROR: ROLLBACK AND CHAIN can only be used in transaction blocks -SELECT * FROM abc ORDER BY 1; +SELECT * FROM trans_abc ORDER BY 1; a --- 1 @@ -898,7 +898,7 @@ SELECT * FROM abc ORDER BY 1; (4 rows) RESET default_transaction_read_only; -DROP TABLE abc; +DROP TABLE trans_abc; -- Test assorted behaviors around the implicit transaction block created -- when multiple SQL commands are sent in a single Query message. These -- tests rely on the fact that psql will not break SQL commands apart at a @@ -1056,21 +1056,21 @@ SHOW transaction_read_only; off (1 row) -CREATE TABLE abc (a int); +CREATE TABLE trans_abc (a int); -- COMMIT/ROLLBACK + COMMIT/ROLLBACK AND CHAIN -INSERT INTO abc VALUES (7)\; COMMIT\; INSERT INTO abc VALUES (8)\; COMMIT AND CHAIN; -- 7 commit, 8 error +INSERT INTO trans_abc VALUES (7)\; COMMIT\; INSERT INTO trans_abc VALUES (8)\; COMMIT AND CHAIN; -- 7 commit, 8 error WARNING: there is no transaction in progress ERROR: COMMIT AND CHAIN can only be used in transaction blocks -INSERT INTO abc VALUES (9)\; ROLLBACK\; INSERT INTO abc VALUES (10)\; ROLLBACK AND CHAIN; -- 9 rollback, 10 error +INSERT INTO trans_abc VALUES (9)\; ROLLBACK\; INSERT INTO trans_abc VALUES (10)\; ROLLBACK AND CHAIN; -- 9 rollback, 10 error WARNING: there is no transaction in progress ERROR: ROLLBACK AND CHAIN can only be used in transaction blocks -- COMMIT/ROLLBACK AND CHAIN + COMMIT/ROLLBACK -INSERT INTO abc VALUES (11)\; COMMIT AND CHAIN\; INSERT INTO abc VALUES (12)\; COMMIT; -- 11 error, 12 not reached +INSERT INTO trans_abc VALUES (11)\; COMMIT AND CHAIN\; INSERT INTO trans_abc VALUES (12)\; COMMIT; -- 11 error, 12 not reached ERROR: COMMIT AND CHAIN can only be used in transaction blocks -INSERT INTO abc VALUES (13)\; ROLLBACK AND CHAIN\; INSERT INTO abc VALUES (14)\; ROLLBACK; -- 13 error, 14 not reached +INSERT INTO trans_abc VALUES (13)\; ROLLBACK AND CHAIN\; INSERT INTO trans_abc VALUES (14)\; ROLLBACK; -- 13 error, 14 not reached ERROR: ROLLBACK AND CHAIN can only be used in transaction blocks -- START TRANSACTION + COMMIT/ROLLBACK AND CHAIN -START TRANSACTION ISOLATION LEVEL REPEATABLE READ\; INSERT INTO abc VALUES (15)\; COMMIT AND CHAIN; -- 15 ok +START TRANSACTION ISOLATION LEVEL REPEATABLE READ\; INSERT INTO trans_abc VALUES (15)\; COMMIT AND CHAIN; -- 15 ok SHOW transaction_isolation; -- transaction is active at this point transaction_isolation ----------------------- @@ -1078,7 +1078,7 @@ SHOW transaction_isolation; -- transaction is active at this point (1 row) COMMIT; -START TRANSACTION ISOLATION LEVEL REPEATABLE READ\; INSERT INTO abc VALUES (16)\; ROLLBACK AND CHAIN; -- 16 ok +START TRANSACTION ISOLATION LEVEL REPEATABLE READ\; INSERT INTO trans_abc VALUES (16)\; ROLLBACK AND CHAIN; -- 16 ok SHOW transaction_isolation; -- transaction is active at this point transaction_isolation ----------------------- @@ -1088,7 +1088,7 @@ SHOW transaction_isolation; -- transaction is active at this point ROLLBACK; SET default_transaction_isolation = 'read committed'; -- START TRANSACTION + COMMIT/ROLLBACK + COMMIT/ROLLBACK AND CHAIN -START TRANSACTION ISOLATION LEVEL REPEATABLE READ\; INSERT INTO abc VALUES (17)\; COMMIT\; INSERT INTO abc VALUES (18)\; COMMIT AND CHAIN; -- 17 commit, 18 error +START TRANSACTION ISOLATION LEVEL REPEATABLE READ\; INSERT INTO trans_abc VALUES (17)\; COMMIT\; INSERT INTO trans_abc VALUES (18)\; COMMIT AND CHAIN; -- 17 commit, 18 error ERROR: COMMIT AND CHAIN can only be used in transaction blocks SHOW transaction_isolation; -- out of transaction block transaction_isolation @@ -1096,7 +1096,7 @@ SHOW transaction_isolation; -- out of transaction block read committed (1 row) -START TRANSACTION ISOLATION LEVEL REPEATABLE READ\; INSERT INTO abc VALUES (19)\; ROLLBACK\; INSERT INTO abc VALUES (20)\; ROLLBACK AND CHAIN; -- 19 rollback, 20 error +START TRANSACTION ISOLATION LEVEL REPEATABLE READ\; INSERT INTO trans_abc VALUES (19)\; ROLLBACK\; INSERT INTO trans_abc VALUES (20)\; ROLLBACK AND CHAIN; -- 19 rollback, 20 error ERROR: ROLLBACK AND CHAIN can only be used in transaction blocks SHOW transaction_isolation; -- out of transaction block transaction_isolation @@ -1105,7 +1105,7 @@ SHOW transaction_isolation; -- out of transaction block (1 row) RESET default_transaction_isolation; -SELECT * FROM abc ORDER BY 1; +SELECT * FROM trans_abc ORDER BY 1; a ---- 7 @@ -1113,7 +1113,7 @@ SELECT * FROM abc ORDER BY 1; 17 (3 rows) -DROP TABLE abc; +DROP TABLE trans_abc; -- Test for successful cleanup of an aborted transaction at session exit. -- THIS MUST BE THE LAST TEST IN THIS FILE. begin; diff --git a/src/test/regress/sql/transactions.sql b/src/test/regress/sql/transactions.sql index d71c3ce93e..912cf8b121 100644 --- a/src/test/regress/sql/transactions.sql +++ b/src/test/regress/sql/transactions.sql @@ -360,10 +360,10 @@ drop function inverse(int); begin; savepoint x; -create table abc (a int); -insert into abc values (5); -insert into abc values (10); -declare foo cursor for select * from abc; +create table trans_abc (a int); +insert into trans_abc values (5); +insert into trans_abc values (10); +declare foo cursor for select * from trans_abc; fetch from foo; rollback to x; @@ -373,11 +373,11 @@ commit; begin; -create table abc (a int); -insert into abc values (5); -insert into abc values (10); -insert into abc values (15); -declare foo cursor for select * from abc; +create table trans_abc (a int); +insert into trans_abc values (5); +insert into trans_abc values (10); +insert into trans_abc values (15); +declare foo cursor for select * from trans_abc; fetch from foo; @@ -423,7 +423,7 @@ DROP FUNCTION invert(x float8); -- Tests for AND CHAIN -CREATE TABLE abc (a int); +CREATE TABLE trans_abc (a int); -- set nondefault value so we have something to override below SET default_transaction_read_only = on; @@ -432,19 +432,19 @@ START TRANSACTION ISOLATION LEVEL REPEATABLE READ, READ WRITE, DEFERRABLE; SHOW transaction_isolation; SHOW transaction_read_only; SHOW transaction_deferrable; -INSERT INTO abc VALUES (1); -INSERT INTO abc VALUES (2); +INSERT INTO trans_abc VALUES (1); +INSERT INTO trans_abc VALUES (2); COMMIT AND CHAIN; -- TBLOCK_END SHOW transaction_isolation; SHOW transaction_read_only; SHOW transaction_deferrable; -INSERT INTO abc VALUES ('error'); -INSERT INTO abc VALUES (3); -- check it's really aborted +INSERT INTO trans_abc VALUES ('error'); +INSERT INTO trans_abc VALUES (3); -- check it's really aborted COMMIT AND CHAIN; -- TBLOCK_ABORT_END SHOW transaction_isolation; SHOW transaction_read_only; SHOW transaction_deferrable; -INSERT INTO abc VALUES (4); +INSERT INTO trans_abc VALUES (4); COMMIT; START TRANSACTION ISOLATION LEVEL REPEATABLE READ, READ WRITE, DEFERRABLE; @@ -452,12 +452,12 @@ SHOW transaction_isolation; SHOW transaction_read_only; SHOW transaction_deferrable; SAVEPOINT x; -INSERT INTO abc VALUES ('error'); +INSERT INTO trans_abc VALUES ('error'); COMMIT AND CHAIN; -- TBLOCK_ABORT_PENDING SHOW transaction_isolation; SHOW transaction_read_only; SHOW transaction_deferrable; -INSERT INTO abc VALUES (5); +INSERT INTO trans_abc VALUES (5); COMMIT; START TRANSACTION ISOLATION LEVEL REPEATABLE READ, READ WRITE, DEFERRABLE; @@ -476,12 +476,12 @@ START TRANSACTION ISOLATION LEVEL SERIALIZABLE, READ WRITE, NOT DEFERRABLE; SHOW transaction_isolation; SHOW transaction_read_only; SHOW transaction_deferrable; -INSERT INTO abc VALUES (6); +INSERT INTO trans_abc VALUES (6); ROLLBACK AND CHAIN; -- TBLOCK_ABORT_PENDING SHOW transaction_isolation; SHOW transaction_read_only; SHOW transaction_deferrable; -INSERT INTO abc VALUES ('error'); +INSERT INTO trans_abc VALUES ('error'); ROLLBACK AND CHAIN; -- TBLOCK_ABORT_END SHOW transaction_isolation; SHOW transaction_read_only; @@ -492,11 +492,11 @@ ROLLBACK; COMMIT AND CHAIN; -- error ROLLBACK AND CHAIN; -- error -SELECT * FROM abc ORDER BY 1; +SELECT * FROM trans_abc ORDER BY 1; RESET default_transaction_read_only; -DROP TABLE abc; +DROP TABLE trans_abc; -- Test assorted behaviors around the implicit transaction block created @@ -561,39 +561,39 @@ SHOW transaction_read_only; SET TRANSACTION READ ONLY\; ROLLBACK AND CHAIN; -- error SHOW transaction_read_only; -CREATE TABLE abc (a int); +CREATE TABLE trans_abc (a int); -- COMMIT/ROLLBACK + COMMIT/ROLLBACK AND CHAIN -INSERT INTO abc VALUES (7)\; COMMIT\; INSERT INTO abc VALUES (8)\; COMMIT AND CHAIN; -- 7 commit, 8 error -INSERT INTO abc VALUES (9)\; ROLLBACK\; INSERT INTO abc VALUES (10)\; ROLLBACK AND CHAIN; -- 9 rollback, 10 error +INSERT INTO trans_abc VALUES (7)\; COMMIT\; INSERT INTO trans_abc VALUES (8)\; COMMIT AND CHAIN; -- 7 commit, 8 error +INSERT INTO trans_abc VALUES (9)\; ROLLBACK\; INSERT INTO trans_abc VALUES (10)\; ROLLBACK AND CHAIN; -- 9 rollback, 10 error -- COMMIT/ROLLBACK AND CHAIN + COMMIT/ROLLBACK -INSERT INTO abc VALUES (11)\; COMMIT AND CHAIN\; INSERT INTO abc VALUES (12)\; COMMIT; -- 11 error, 12 not reached -INSERT INTO abc VALUES (13)\; ROLLBACK AND CHAIN\; INSERT INTO abc VALUES (14)\; ROLLBACK; -- 13 error, 14 not reached +INSERT INTO trans_abc VALUES (11)\; COMMIT AND CHAIN\; INSERT INTO trans_abc VALUES (12)\; COMMIT; -- 11 error, 12 not reached +INSERT INTO trans_abc VALUES (13)\; ROLLBACK AND CHAIN\; INSERT INTO trans_abc VALUES (14)\; ROLLBACK; -- 13 error, 14 not reached -- START TRANSACTION + COMMIT/ROLLBACK AND CHAIN -START TRANSACTION ISOLATION LEVEL REPEATABLE READ\; INSERT INTO abc VALUES (15)\; COMMIT AND CHAIN; -- 15 ok +START TRANSACTION ISOLATION LEVEL REPEATABLE READ\; INSERT INTO trans_abc VALUES (15)\; COMMIT AND CHAIN; -- 15 ok SHOW transaction_isolation; -- transaction is active at this point COMMIT; -START TRANSACTION ISOLATION LEVEL REPEATABLE READ\; INSERT INTO abc VALUES (16)\; ROLLBACK AND CHAIN; -- 16 ok +START TRANSACTION ISOLATION LEVEL REPEATABLE READ\; INSERT INTO trans_abc VALUES (16)\; ROLLBACK AND CHAIN; -- 16 ok SHOW transaction_isolation; -- transaction is active at this point ROLLBACK; SET default_transaction_isolation = 'read committed'; -- START TRANSACTION + COMMIT/ROLLBACK + COMMIT/ROLLBACK AND CHAIN -START TRANSACTION ISOLATION LEVEL REPEATABLE READ\; INSERT INTO abc VALUES (17)\; COMMIT\; INSERT INTO abc VALUES (18)\; COMMIT AND CHAIN; -- 17 commit, 18 error +START TRANSACTION ISOLATION LEVEL REPEATABLE READ\; INSERT INTO trans_abc VALUES (17)\; COMMIT\; INSERT INTO trans_abc VALUES (18)\; COMMIT AND CHAIN; -- 17 commit, 18 error SHOW transaction_isolation; -- out of transaction block -START TRANSACTION ISOLATION LEVEL REPEATABLE READ\; INSERT INTO abc VALUES (19)\; ROLLBACK\; INSERT INTO abc VALUES (20)\; ROLLBACK AND CHAIN; -- 19 rollback, 20 error +START TRANSACTION ISOLATION LEVEL REPEATABLE READ\; INSERT INTO trans_abc VALUES (19)\; ROLLBACK\; INSERT INTO trans_abc VALUES (20)\; ROLLBACK AND CHAIN; -- 19 rollback, 20 error SHOW transaction_isolation; -- out of transaction block RESET default_transaction_isolation; -SELECT * FROM abc ORDER BY 1; +SELECT * FROM trans_abc ORDER BY 1; -DROP TABLE abc; +DROP TABLE trans_abc; -- Test for successful cleanup of an aborted transaction at session exit.