On Wed, 2005-01-26 at 12:02 -0300, Alvaro Herrera wrote:
> > and some regression tests for this behavior, but I'm happy to add that
> > myself if no one beats me to it.
> 
> Please do.

Attached is a patch adding regression tests for this change -- I've
already applied it to HEAD.

-Neil

Index: src/test/regress/expected/transactions.out
===================================================================
RCS file: /var/lib/cvs/pgsql/src/test/regress/expected/transactions.out,v
retrieving revision 1.10
diff -c -r1.10 transactions.out
*** src/test/regress/expected/transactions.out	13 Sep 2004 20:09:51 -0000	1.10
--- src/test/regress/expected/transactions.out	27 Jan 2005 01:25:43 -0000
***************
*** 470,472 ****
--- 470,519 ----
  DROP TABLE foo;
  DROP TABLE baz;
  DROP TABLE barbaz;
+ -- verify that cursors created during an aborted subtransaction are
+ -- closed, but that we do not rollback the effect of any FETCHs
+ -- performed in the aborted subtransaction
+ begin;
+ savepoint x;
+ create table abc (a int);
+ insert into abc values (5);
+ insert into abc values (10);
+ declare foo cursor for select * from abc;
+ fetch from foo;
+  a 
+ ---
+  5
+ (1 row)
+ 
+ rollback to x;
+ -- should fail
+ fetch from foo;
+ ERROR:  cursor "foo" does not exist
+ commit;
+ begin;
+ create table abc (a int);
+ insert into abc values (5);
+ insert into abc values (10);
+ insert into abc values (15);
+ declare foo cursor for select * from abc;
+ fetch from foo;
+  a 
+ ---
+  5
+ (1 row)
+ 
+ savepoint x;
+ fetch from foo;
+  a  
+ ----
+  10
+ (1 row)
+ 
+ rollback to x;
+ fetch from foo;
+  a  
+ ----
+  15
+ (1 row)
+ 
+ abort;
Index: src/test/regress/sql/transactions.sql
===================================================================
RCS file: /var/lib/cvs/pgsql/src/test/regress/sql/transactions.sql,v
retrieving revision 1.10
diff -c -r1.10 transactions.sql
*** src/test/regress/sql/transactions.sql	13 Sep 2004 20:10:13 -0000	1.10
--- src/test/regress/sql/transactions.sql	27 Jan 2005 01:23:37 -0000
***************
*** 290,292 ****
--- 290,327 ----
  DROP TABLE foo;
  DROP TABLE baz;
  DROP TABLE barbaz;
+ 
+ -- verify that cursors created during an aborted subtransaction are
+ -- closed, but that we do not rollback the effect of any FETCHs
+ -- performed in the aborted subtransaction
+ begin;
+ 
+ savepoint x;
+ create table abc (a int);
+ insert into abc values (5);
+ insert into abc values (10);
+ declare foo cursor for select * from abc;
+ fetch from foo;
+ rollback to x;
+ 
+ -- should fail
+ fetch from foo;
+ commit;
+ 
+ begin;
+ 
+ create table abc (a int);
+ insert into abc values (5);
+ insert into abc values (10);
+ insert into abc values (15);
+ declare foo cursor for select * from abc;
+ 
+ fetch from foo;
+ 
+ savepoint x;
+ fetch from foo;
+ rollback to x;
+ 
+ fetch from foo;
+ 
+ abort;
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]

Reply via email to