diff options
| author | Tom Lane | 2004-07-17 03:32:14 +0000 |
|---|---|---|
| committer | Tom Lane | 2004-07-17 03:32:14 +0000 |
| commit | fe548629c50b753e96515ba2cfd8a85e8fba10de (patch) | |
| tree | e80b54f71cb7868db3f9f9c97bccf4c48859951a /src/test | |
| parent | f4c069ca8fc80640bd1bff510697371ffaf45267 (diff) | |
Invent ResourceOwner mechanism as per my recent proposal, and use it to
keep track of portal-related resources separately from transaction-related
resources. This allows cursors to work in a somewhat sane fashion with
nested transactions. For now, cursor behavior is non-subtransactional,
that is a cursor's state does not roll back if you abort a subtransaction
that fetched from the cursor. We might want to change that later.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/regress/expected/transactions.out | 66 | ||||
| -rw-r--r-- | src/test/regress/sql/transactions.sql | 22 |
2 files changed, 88 insertions, 0 deletions
diff --git a/src/test/regress/expected/transactions.out b/src/test/regress/expected/transactions.out index c2fdc231039..cc3004dbb28 100644 --- a/src/test/regress/expected/transactions.out +++ b/src/test/regress/expected/transactions.out @@ -191,6 +191,72 @@ SELECT 1; -- this should work 1 (1 row) +-- check non-transactional behavior of cursors +BEGIN; + DECLARE c CURSOR FOR SELECT unique2 FROM tenk1; + BEGIN; + FETCH 10 FROM c; + unique2 +--------- + 0 + 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 +(10 rows) + + ROLLBACK; + BEGIN; + FETCH 10 FROM c; + unique2 +--------- + 10 + 11 + 12 + 13 + 14 + 15 + 16 + 17 + 18 + 19 +(10 rows) + + COMMIT; + FETCH 10 FROM c; + unique2 +--------- + 20 + 21 + 22 + 23 + 24 + 25 + 26 + 27 + 28 + 29 +(10 rows) + + CLOSE c; + DECLARE c CURSOR FOR SELECT unique2/0 FROM tenk1; + BEGIN; + FETCH 10 FROM c; +ERROR: division by zero + ROLLBACK; + -- c is now dead to the world ... + BEGIN; + FETCH 10 FROM c; +ERROR: portal "c" cannot be run + ROLLBACK; + FETCH 10 FROM c; +ERROR: portal "c" cannot be run +COMMIT; 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 5af024fdfe6..f2a206979fe 100644 --- a/src/test/regress/sql/transactions.sql +++ b/src/test/regress/sql/transactions.sql @@ -127,6 +127,28 @@ BEGIN; COMMIT; SELECT 1; -- this should work +-- check non-transactional behavior of cursors +BEGIN; + DECLARE c CURSOR FOR SELECT unique2 FROM tenk1; + BEGIN; + FETCH 10 FROM c; + ROLLBACK; + BEGIN; + FETCH 10 FROM c; + COMMIT; + FETCH 10 FROM c; + CLOSE c; + DECLARE c CURSOR FOR SELECT unique2/0 FROM tenk1; + BEGIN; + FETCH 10 FROM c; + ROLLBACK; + -- c is now dead to the world ... + BEGIN; + FETCH 10 FROM c; + ROLLBACK; + FETCH 10 FROM c; +COMMIT; + DROP TABLE foo; DROP TABLE baz; |
