1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-12 02:37:31 +03:00

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.
This commit is contained in:
Tom Lane
2004-07-17 03:32:14 +00:00
parent f4c069ca8f
commit fe548629c5
41 changed files with 2086 additions and 1192 deletions

View File

@@ -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;

View File

@@ -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;