diff options
| author | Tom Lane | 2004-07-01 20:11:03 +0000 |
|---|---|---|
| committer | Tom Lane | 2004-07-01 20:11:03 +0000 |
| commit | b6197fe06939d35f67abee1ebe62690d43199783 (patch) | |
| tree | e6c486cb0c2d752f42197f04dddeaaabd2395ec8 /src/test | |
| parent | e15d0bb8e8d5d6c8c9de8ba80c1756a773dbe445 (diff) | |
Further review of xact.c state machine for nested transactions. Fix
problems with starting subtransactions inside already-failed transactions.
Clean up some comments.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/transactions.out | 59 | ||||
| -rw-r--r-- | src/test/regress/sql/transactions.sql | 32 |
2 files changed, 91 insertions, 0 deletions
diff --git a/src/test/regress/expected/transactions.out b/src/test/regress/expected/transactions.out index 6cc89b5c5e4..c2fdc231039 100644 --- a/src/test/regress/expected/transactions.out +++ b/src/test/regress/expected/transactions.out @@ -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; diff --git a/src/test/regress/sql/transactions.sql b/src/test/regress/sql/transactions.sql index a656c393b4f..5af024fdfe6 100644 --- a/src/test/regress/sql/transactions.sql +++ b/src/test/regress/sql/transactions.sql @@ -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; |
