Skip to content

Commit b973f93

Browse files
committed
Avoid naming conflict between transactions.sql and namespace.sql.
Commits 681d9e4 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 2cf8c7a.) Marina Polyakova Discussion: https://postgr.es/m/80d0201636665d82185942e7112257b4@postgrespro.ru
1 parent 803b4a2 commit b973f93

File tree

2 files changed

+70
-70
lines changed

2 files changed

+70
-70
lines changed

src/test/regress/expected/transactions.out

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -609,10 +609,10 @@ drop function inverse(int);
609609
-- performed in the aborted subtransaction
610610
begin;
611611
savepoint x;
612-
create table abc (a int);
613-
insert into abc values (5);
614-
insert into abc values (10);
615-
declare foo cursor for select * from abc;
612+
create table trans_abc (a int);
613+
insert into trans_abc values (5);
614+
insert into trans_abc values (10);
615+
declare foo cursor for select * from trans_abc;
616616
fetch from foo;
617617
a
618618
---
@@ -625,11 +625,11 @@ fetch from foo;
625625
ERROR: cursor "foo" does not exist
626626
commit;
627627
begin;
628-
create table abc (a int);
629-
insert into abc values (5);
630-
insert into abc values (10);
631-
insert into abc values (15);
632-
declare foo cursor for select * from abc;
628+
create table trans_abc (a int);
629+
insert into trans_abc values (5);
630+
insert into trans_abc values (10);
631+
insert into trans_abc values (15);
632+
declare foo cursor for select * from trans_abc;
633633
fetch from foo;
634634
a
635635
---
@@ -698,7 +698,7 @@ COMMIT;
698698
DROP FUNCTION create_temp_tab();
699699
DROP FUNCTION invert(x float8);
700700
-- Tests for AND CHAIN
701-
CREATE TABLE abc (a int);
701+
CREATE TABLE trans_abc (a int);
702702
-- set nondefault value so we have something to override below
703703
SET default_transaction_read_only = on;
704704
START TRANSACTION ISOLATION LEVEL REPEATABLE READ, READ WRITE, DEFERRABLE;
@@ -720,8 +720,8 @@ SHOW transaction_deferrable;
720720
on
721721
(1 row)
722722

723-
INSERT INTO abc VALUES (1);
724-
INSERT INTO abc VALUES (2);
723+
INSERT INTO trans_abc VALUES (1);
724+
INSERT INTO trans_abc VALUES (2);
725725
COMMIT AND CHAIN; -- TBLOCK_END
726726
SHOW transaction_isolation;
727727
transaction_isolation
@@ -741,11 +741,11 @@ SHOW transaction_deferrable;
741741
on
742742
(1 row)
743743

744-
INSERT INTO abc VALUES ('error');
744+
INSERT INTO trans_abc VALUES ('error');
745745
ERROR: invalid input syntax for type integer: "error"
746-
LINE 1: INSERT INTO abc VALUES ('error');
747-
^
748-
INSERT INTO abc VALUES (3); -- check it's really aborted
746+
LINE 1: INSERT INTO trans_abc VALUES ('error');
747+
^
748+
INSERT INTO trans_abc VALUES (3); -- check it's really aborted
749749
ERROR: current transaction is aborted, commands ignored until end of transaction block
750750
COMMIT AND CHAIN; -- TBLOCK_ABORT_END
751751
SHOW transaction_isolation;
@@ -766,7 +766,7 @@ SHOW transaction_deferrable;
766766
on
767767
(1 row)
768768

769-
INSERT INTO abc VALUES (4);
769+
INSERT INTO trans_abc VALUES (4);
770770
COMMIT;
771771
START TRANSACTION ISOLATION LEVEL REPEATABLE READ, READ WRITE, DEFERRABLE;
772772
SHOW transaction_isolation;
@@ -788,10 +788,10 @@ SHOW transaction_deferrable;
788788
(1 row)
789789

790790
SAVEPOINT x;
791-
INSERT INTO abc VALUES ('error');
791+
INSERT INTO trans_abc VALUES ('error');
792792
ERROR: invalid input syntax for type integer: "error"
793-
LINE 1: INSERT INTO abc VALUES ('error');
794-
^
793+
LINE 1: INSERT INTO trans_abc VALUES ('error');
794+
^
795795
COMMIT AND CHAIN; -- TBLOCK_ABORT_PENDING
796796
SHOW transaction_isolation;
797797
transaction_isolation
@@ -811,7 +811,7 @@ SHOW transaction_deferrable;
811811
on
812812
(1 row)
813813

814-
INSERT INTO abc VALUES (5);
814+
INSERT INTO trans_abc VALUES (5);
815815
COMMIT;
816816
START TRANSACTION ISOLATION LEVEL REPEATABLE READ, READ WRITE, DEFERRABLE;
817817
SHOW transaction_isolation;
@@ -873,7 +873,7 @@ SHOW transaction_deferrable;
873873
off
874874
(1 row)
875875

876-
INSERT INTO abc VALUES (6);
876+
INSERT INTO trans_abc VALUES (6);
877877
ROLLBACK AND CHAIN; -- TBLOCK_ABORT_PENDING
878878
SHOW transaction_isolation;
879879
transaction_isolation
@@ -893,10 +893,10 @@ SHOW transaction_deferrable;
893893
off
894894
(1 row)
895895

896-
INSERT INTO abc VALUES ('error');
896+
INSERT INTO trans_abc VALUES ('error');
897897
ERROR: invalid input syntax for type integer: "error"
898-
LINE 1: INSERT INTO abc VALUES ('error');
899-
^
898+
LINE 1: INSERT INTO trans_abc VALUES ('error');
899+
^
900900
ROLLBACK AND CHAIN; -- TBLOCK_ABORT_END
901901
SHOW transaction_isolation;
902902
transaction_isolation
@@ -922,7 +922,7 @@ COMMIT AND CHAIN; -- error
922922
ERROR: COMMIT AND CHAIN can only be used in transaction blocks
923923
ROLLBACK AND CHAIN; -- error
924924
ERROR: ROLLBACK AND CHAIN can only be used in transaction blocks
925-
SELECT * FROM abc ORDER BY 1;
925+
SELECT * FROM trans_abc ORDER BY 1;
926926
a
927927
---
928928
1
@@ -932,7 +932,7 @@ SELECT * FROM abc ORDER BY 1;
932932
(4 rows)
933933

934934
RESET default_transaction_read_only;
935-
DROP TABLE abc;
935+
DROP TABLE trans_abc;
936936
-- Test assorted behaviors around the implicit transaction block created
937937
-- when multiple SQL commands are sent in a single Query message. These
938938
-- tests rely on the fact that psql will not break SQL commands apart at a
@@ -1090,29 +1090,29 @@ SHOW transaction_read_only;
10901090
off
10911091
(1 row)
10921092

1093-
CREATE TABLE abc (a int);
1093+
CREATE TABLE trans_abc (a int);
10941094
-- COMMIT/ROLLBACK + COMMIT/ROLLBACK AND CHAIN
1095-
INSERT INTO abc VALUES (7)\; COMMIT\; INSERT INTO abc VALUES (8)\; COMMIT AND CHAIN; -- 7 commit, 8 error
1095+
INSERT INTO trans_abc VALUES (7)\; COMMIT\; INSERT INTO trans_abc VALUES (8)\; COMMIT AND CHAIN; -- 7 commit, 8 error
10961096
WARNING: there is no transaction in progress
10971097
ERROR: COMMIT AND CHAIN can only be used in transaction blocks
1098-
INSERT INTO abc VALUES (9)\; ROLLBACK\; INSERT INTO abc VALUES (10)\; ROLLBACK AND CHAIN; -- 9 rollback, 10 error
1098+
INSERT INTO trans_abc VALUES (9)\; ROLLBACK\; INSERT INTO trans_abc VALUES (10)\; ROLLBACK AND CHAIN; -- 9 rollback, 10 error
10991099
WARNING: there is no transaction in progress
11001100
ERROR: ROLLBACK AND CHAIN can only be used in transaction blocks
11011101
-- COMMIT/ROLLBACK AND CHAIN + COMMIT/ROLLBACK
1102-
INSERT INTO abc VALUES (11)\; COMMIT AND CHAIN\; INSERT INTO abc VALUES (12)\; COMMIT; -- 11 error, 12 not reached
1102+
INSERT INTO trans_abc VALUES (11)\; COMMIT AND CHAIN\; INSERT INTO trans_abc VALUES (12)\; COMMIT; -- 11 error, 12 not reached
11031103
ERROR: COMMIT AND CHAIN can only be used in transaction blocks
1104-
INSERT INTO abc VALUES (13)\; ROLLBACK AND CHAIN\; INSERT INTO abc VALUES (14)\; ROLLBACK; -- 13 error, 14 not reached
1104+
INSERT INTO trans_abc VALUES (13)\; ROLLBACK AND CHAIN\; INSERT INTO trans_abc VALUES (14)\; ROLLBACK; -- 13 error, 14 not reached
11051105
ERROR: ROLLBACK AND CHAIN can only be used in transaction blocks
11061106
-- START TRANSACTION + COMMIT/ROLLBACK AND CHAIN
1107-
START TRANSACTION ISOLATION LEVEL REPEATABLE READ\; INSERT INTO abc VALUES (15)\; COMMIT AND CHAIN; -- 15 ok
1107+
START TRANSACTION ISOLATION LEVEL REPEATABLE READ\; INSERT INTO trans_abc VALUES (15)\; COMMIT AND CHAIN; -- 15 ok
11081108
SHOW transaction_isolation; -- transaction is active at this point
11091109
transaction_isolation
11101110
-----------------------
11111111
repeatable read
11121112
(1 row)
11131113

11141114
COMMIT;
1115-
START TRANSACTION ISOLATION LEVEL REPEATABLE READ\; INSERT INTO abc VALUES (16)\; ROLLBACK AND CHAIN; -- 16 ok
1115+
START TRANSACTION ISOLATION LEVEL REPEATABLE READ\; INSERT INTO trans_abc VALUES (16)\; ROLLBACK AND CHAIN; -- 16 ok
11161116
SHOW transaction_isolation; -- transaction is active at this point
11171117
transaction_isolation
11181118
-----------------------
@@ -1122,15 +1122,15 @@ SHOW transaction_isolation; -- transaction is active at this point
11221122
ROLLBACK;
11231123
SET default_transaction_isolation = 'read committed';
11241124
-- START TRANSACTION + COMMIT/ROLLBACK + COMMIT/ROLLBACK AND CHAIN
1125-
START TRANSACTION ISOLATION LEVEL REPEATABLE READ\; INSERT INTO abc VALUES (17)\; COMMIT\; INSERT INTO abc VALUES (18)\; COMMIT AND CHAIN; -- 17 commit, 18 error
1125+
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
11261126
ERROR: COMMIT AND CHAIN can only be used in transaction blocks
11271127
SHOW transaction_isolation; -- out of transaction block
11281128
transaction_isolation
11291129
-----------------------
11301130
read committed
11311131
(1 row)
11321132

1133-
START TRANSACTION ISOLATION LEVEL REPEATABLE READ\; INSERT INTO abc VALUES (19)\; ROLLBACK\; INSERT INTO abc VALUES (20)\; ROLLBACK AND CHAIN; -- 19 rollback, 20 error
1133+
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
11341134
ERROR: ROLLBACK AND CHAIN can only be used in transaction blocks
11351135
SHOW transaction_isolation; -- out of transaction block
11361136
transaction_isolation
@@ -1139,15 +1139,15 @@ SHOW transaction_isolation; -- out of transaction block
11391139
(1 row)
11401140

11411141
RESET default_transaction_isolation;
1142-
SELECT * FROM abc ORDER BY 1;
1142+
SELECT * FROM trans_abc ORDER BY 1;
11431143
a
11441144
----
11451145
7
11461146
15
11471147
17
11481148
(3 rows)
11491149

1150-
DROP TABLE abc;
1150+
DROP TABLE trans_abc;
11511151
-- Test for successful cleanup of an aborted transaction at session exit.
11521152
-- THIS MUST BE THE LAST TEST IN THIS FILE.
11531153
begin;

src/test/regress/sql/transactions.sql

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -378,10 +378,10 @@ drop function inverse(int);
378378
begin;
379379

380380
savepoint x;
381-
create table abc (a int);
382-
insert into abc values (5);
383-
insert into abc values (10);
384-
declare foo cursor for select * from abc;
381+
create table trans_abc (a int);
382+
insert into trans_abc values (5);
383+
insert into trans_abc values (10);
384+
declare foo cursor for select * from trans_abc;
385385
fetch from foo;
386386
rollback to x;
387387

@@ -391,11 +391,11 @@ commit;
391391

392392
begin;
393393

394-
create table abc (a int);
395-
insert into abc values (5);
396-
insert into abc values (10);
397-
insert into abc values (15);
398-
declare foo cursor for select * from abc;
394+
create table trans_abc (a int);
395+
insert into trans_abc values (5);
396+
insert into trans_abc values (10);
397+
insert into trans_abc values (15);
398+
declare foo cursor for select * from trans_abc;
399399

400400
fetch from foo;
401401

@@ -441,7 +441,7 @@ DROP FUNCTION invert(x float8);
441441

442442
-- Tests for AND CHAIN
443443

444-
CREATE TABLE abc (a int);
444+
CREATE TABLE trans_abc (a int);
445445

446446
-- set nondefault value so we have something to override below
447447
SET default_transaction_read_only = on;
@@ -450,32 +450,32 @@ START TRANSACTION ISOLATION LEVEL REPEATABLE READ, READ WRITE, DEFERRABLE;
450450
SHOW transaction_isolation;
451451
SHOW transaction_read_only;
452452
SHOW transaction_deferrable;
453-
INSERT INTO abc VALUES (1);
454-
INSERT INTO abc VALUES (2);
453+
INSERT INTO trans_abc VALUES (1);
454+
INSERT INTO trans_abc VALUES (2);
455455
COMMIT AND CHAIN; -- TBLOCK_END
456456
SHOW transaction_isolation;
457457
SHOW transaction_read_only;
458458
SHOW transaction_deferrable;
459-
INSERT INTO abc VALUES ('error');
460-
INSERT INTO abc VALUES (3); -- check it's really aborted
459+
INSERT INTO trans_abc VALUES ('error');
460+
INSERT INTO trans_abc VALUES (3); -- check it's really aborted
461461
COMMIT AND CHAIN; -- TBLOCK_ABORT_END
462462
SHOW transaction_isolation;
463463
SHOW transaction_read_only;
464464
SHOW transaction_deferrable;
465-
INSERT INTO abc VALUES (4);
465+
INSERT INTO trans_abc VALUES (4);
466466
COMMIT;
467467

468468
START TRANSACTION ISOLATION LEVEL REPEATABLE READ, READ WRITE, DEFERRABLE;
469469
SHOW transaction_isolation;
470470
SHOW transaction_read_only;
471471
SHOW transaction_deferrable;
472472
SAVEPOINT x;
473-
INSERT INTO abc VALUES ('error');
473+
INSERT INTO trans_abc VALUES ('error');
474474
COMMIT AND CHAIN; -- TBLOCK_ABORT_PENDING
475475
SHOW transaction_isolation;
476476
SHOW transaction_read_only;
477477
SHOW transaction_deferrable;
478-
INSERT INTO abc VALUES (5);
478+
INSERT INTO trans_abc VALUES (5);
479479
COMMIT;
480480

481481
START TRANSACTION ISOLATION LEVEL REPEATABLE READ, READ WRITE, DEFERRABLE;
@@ -494,12 +494,12 @@ START TRANSACTION ISOLATION LEVEL SERIALIZABLE, READ WRITE, NOT DEFERRABLE;
494494
SHOW transaction_isolation;
495495
SHOW transaction_read_only;
496496
SHOW transaction_deferrable;
497-
INSERT INTO abc VALUES (6);
497+
INSERT INTO trans_abc VALUES (6);
498498
ROLLBACK AND CHAIN; -- TBLOCK_ABORT_PENDING
499499
SHOW transaction_isolation;
500500
SHOW transaction_read_only;
501501
SHOW transaction_deferrable;
502-
INSERT INTO abc VALUES ('error');
502+
INSERT INTO trans_abc VALUES ('error');
503503
ROLLBACK AND CHAIN; -- TBLOCK_ABORT_END
504504
SHOW transaction_isolation;
505505
SHOW transaction_read_only;
@@ -510,11 +510,11 @@ ROLLBACK;
510510
COMMIT AND CHAIN; -- error
511511
ROLLBACK AND CHAIN; -- error
512512

513-
SELECT * FROM abc ORDER BY 1;
513+
SELECT * FROM trans_abc ORDER BY 1;
514514

515515
RESET default_transaction_read_only;
516516

517-
DROP TABLE abc;
517+
DROP TABLE trans_abc;
518518

519519

520520
-- Test assorted behaviors around the implicit transaction block created
@@ -579,39 +579,39 @@ SHOW transaction_read_only;
579579
SET TRANSACTION READ ONLY\; ROLLBACK AND CHAIN; -- error
580580
SHOW transaction_read_only;
581581

582-
CREATE TABLE abc (a int);
582+
CREATE TABLE trans_abc (a int);
583583

584584
-- COMMIT/ROLLBACK + COMMIT/ROLLBACK AND CHAIN
585-
INSERT INTO abc VALUES (7)\; COMMIT\; INSERT INTO abc VALUES (8)\; COMMIT AND CHAIN; -- 7 commit, 8 error
586-
INSERT INTO abc VALUES (9)\; ROLLBACK\; INSERT INTO abc VALUES (10)\; ROLLBACK AND CHAIN; -- 9 rollback, 10 error
585+
INSERT INTO trans_abc VALUES (7)\; COMMIT\; INSERT INTO trans_abc VALUES (8)\; COMMIT AND CHAIN; -- 7 commit, 8 error
586+
INSERT INTO trans_abc VALUES (9)\; ROLLBACK\; INSERT INTO trans_abc VALUES (10)\; ROLLBACK AND CHAIN; -- 9 rollback, 10 error
587587

588588
-- COMMIT/ROLLBACK AND CHAIN + COMMIT/ROLLBACK
589-
INSERT INTO abc VALUES (11)\; COMMIT AND CHAIN\; INSERT INTO abc VALUES (12)\; COMMIT; -- 11 error, 12 not reached
590-
INSERT INTO abc VALUES (13)\; ROLLBACK AND CHAIN\; INSERT INTO abc VALUES (14)\; ROLLBACK; -- 13 error, 14 not reached
589+
INSERT INTO trans_abc VALUES (11)\; COMMIT AND CHAIN\; INSERT INTO trans_abc VALUES (12)\; COMMIT; -- 11 error, 12 not reached
590+
INSERT INTO trans_abc VALUES (13)\; ROLLBACK AND CHAIN\; INSERT INTO trans_abc VALUES (14)\; ROLLBACK; -- 13 error, 14 not reached
591591

592592
-- START TRANSACTION + COMMIT/ROLLBACK AND CHAIN
593-
START TRANSACTION ISOLATION LEVEL REPEATABLE READ\; INSERT INTO abc VALUES (15)\; COMMIT AND CHAIN; -- 15 ok
593+
START TRANSACTION ISOLATION LEVEL REPEATABLE READ\; INSERT INTO trans_abc VALUES (15)\; COMMIT AND CHAIN; -- 15 ok
594594
SHOW transaction_isolation; -- transaction is active at this point
595595
COMMIT;
596596

597-
START TRANSACTION ISOLATION LEVEL REPEATABLE READ\; INSERT INTO abc VALUES (16)\; ROLLBACK AND CHAIN; -- 16 ok
597+
START TRANSACTION ISOLATION LEVEL REPEATABLE READ\; INSERT INTO trans_abc VALUES (16)\; ROLLBACK AND CHAIN; -- 16 ok
598598
SHOW transaction_isolation; -- transaction is active at this point
599599
ROLLBACK;
600600

601601
SET default_transaction_isolation = 'read committed';
602602

603603
-- START TRANSACTION + COMMIT/ROLLBACK + COMMIT/ROLLBACK AND CHAIN
604-
START TRANSACTION ISOLATION LEVEL REPEATABLE READ\; INSERT INTO abc VALUES (17)\; COMMIT\; INSERT INTO abc VALUES (18)\; COMMIT AND CHAIN; -- 17 commit, 18 error
604+
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
605605
SHOW transaction_isolation; -- out of transaction block
606606

607-
START TRANSACTION ISOLATION LEVEL REPEATABLE READ\; INSERT INTO abc VALUES (19)\; ROLLBACK\; INSERT INTO abc VALUES (20)\; ROLLBACK AND CHAIN; -- 19 rollback, 20 error
607+
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
608608
SHOW transaction_isolation; -- out of transaction block
609609

610610
RESET default_transaction_isolation;
611611

612-
SELECT * FROM abc ORDER BY 1;
612+
SELECT * FROM trans_abc ORDER BY 1;
613613

614-
DROP TABLE abc;
614+
DROP TABLE trans_abc;
615615

616616

617617
-- Test for successful cleanup of an aborted transaction at session exit.

0 commit comments

Comments
 (0)