mirror of
https://github.com/postgres/postgres.git
synced 2025-12-12 02:37:31 +03:00
Further review of xact.c state machine for nested transactions. Fix
problems with starting subtransactions inside already-failed transactions. Clean up some comments.
This commit is contained in:
@@ -132,6 +132,65 @@ SELECT * FROM barbaz; -- should have 1
|
||||
1
|
||||
(1 row)
|
||||
|
||||
-- check that starting a subxact in a failed xact or subxact works
|
||||
BEGIN;
|
||||
SELECT 0/0; -- fail the outer xact
|
||||
ERROR: division by zero
|
||||
BEGIN;
|
||||
SELECT 1; -- this should NOT work
|
||||
ERROR: current transaction is aborted, commands ignored until end of transaction block
|
||||
COMMIT;
|
||||
SELECT 1; -- this should NOT work
|
||||
ERROR: current transaction is aborted, commands ignored until end of transaction block
|
||||
BEGIN;
|
||||
SELECT 1; -- this should NOT work
|
||||
ERROR: current transaction is aborted, commands ignored until end of transaction block
|
||||
ROLLBACK;
|
||||
SELECT 1; -- this should NOT work
|
||||
ERROR: current transaction is aborted, commands ignored until end of transaction block
|
||||
COMMIT;
|
||||
SELECT 1; -- this should work
|
||||
?column?
|
||||
----------
|
||||
1
|
||||
(1 row)
|
||||
|
||||
BEGIN;
|
||||
BEGIN;
|
||||
SELECT 1; -- this should work
|
||||
?column?
|
||||
----------
|
||||
1
|
||||
(1 row)
|
||||
|
||||
SELECT 0/0; -- fail the subxact
|
||||
ERROR: division by zero
|
||||
SELECT 1; -- this should NOT work
|
||||
ERROR: current transaction is aborted, commands ignored until end of transaction block
|
||||
BEGIN;
|
||||
SELECT 1; -- this should NOT work
|
||||
ERROR: current transaction is aborted, commands ignored until end of transaction block
|
||||
ROLLBACK;
|
||||
BEGIN;
|
||||
SELECT 1; -- this should NOT work
|
||||
ERROR: current transaction is aborted, commands ignored until end of transaction block
|
||||
COMMIT;
|
||||
SELECT 1; -- this should NOT work
|
||||
ERROR: current transaction is aborted, commands ignored until end of transaction block
|
||||
ROLLBACK;
|
||||
SELECT 1; -- this should work
|
||||
?column?
|
||||
----------
|
||||
1
|
||||
(1 row)
|
||||
|
||||
COMMIT;
|
||||
SELECT 1; -- this should work
|
||||
?column?
|
||||
----------
|
||||
1
|
||||
(1 row)
|
||||
|
||||
DROP TABLE foo;
|
||||
DROP TABLE baz;
|
||||
DROP TABLE barbaz;
|
||||
|
||||
@@ -96,6 +96,38 @@ COMMIT;
|
||||
SELECT * FROM foo; -- should have 1 and 3
|
||||
SELECT * FROM barbaz; -- should have 1
|
||||
|
||||
-- check that starting a subxact in a failed xact or subxact works
|
||||
BEGIN;
|
||||
SELECT 0/0; -- fail the outer xact
|
||||
BEGIN;
|
||||
SELECT 1; -- this should NOT work
|
||||
COMMIT;
|
||||
SELECT 1; -- this should NOT work
|
||||
BEGIN;
|
||||
SELECT 1; -- this should NOT work
|
||||
ROLLBACK;
|
||||
SELECT 1; -- this should NOT work
|
||||
COMMIT;
|
||||
SELECT 1; -- this should work
|
||||
|
||||
BEGIN;
|
||||
BEGIN;
|
||||
SELECT 1; -- this should work
|
||||
SELECT 0/0; -- fail the subxact
|
||||
SELECT 1; -- this should NOT work
|
||||
BEGIN;
|
||||
SELECT 1; -- this should NOT work
|
||||
ROLLBACK;
|
||||
BEGIN;
|
||||
SELECT 1; -- this should NOT work
|
||||
COMMIT;
|
||||
SELECT 1; -- this should NOT work
|
||||
ROLLBACK;
|
||||
SELECT 1; -- this should work
|
||||
COMMIT;
|
||||
SELECT 1; -- this should work
|
||||
|
||||
|
||||
DROP TABLE foo;
|
||||
DROP TABLE baz;
|
||||
DROP TABLE barbaz;
|
||||
|
||||
Reference in New Issue
Block a user