aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNeil Conway <neilc@samurai.com>2005-01-27 01:32:00 +0000
committerNeil Conway <neilc@samurai.com>2005-01-27 01:32:00 +0000
commit4fe201237faef8f30b395f1c5b350ce393f95ad3 (patch)
treecdac8a0d991d0799f090598c46dda7aef5b24da0 /src
parentaba691b728b072211c6d78b2afa341d022aee814 (diff)
downloadpostgresql-4fe201237faef8f30b395f1c5b350ce393f95ad3.tar.gz
postgresql-4fe201237faef8f30b395f1c5b350ce393f95ad3.zip
Add regression tests for recent cursor/savepoint bug fixed by Alvaro and
Tom.
Diffstat (limited to 'src')
-rw-r--r--src/test/regress/expected/transactions.out47
-rw-r--r--src/test/regress/sql/transactions.sql35
2 files changed, 82 insertions, 0 deletions
diff --git a/src/test/regress/expected/transactions.out b/src/test/regress/expected/transactions.out
index 1c8ba64c5c0..952875cfdf1 100644
--- a/src/test/regress/expected/transactions.out
+++ b/src/test/regress/expected/transactions.out
@@ -470,3 +470,50 @@ ROLLBACK;
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;
diff --git a/src/test/regress/sql/transactions.sql b/src/test/regress/sql/transactions.sql
index 0046974402b..6aebfcc867e 100644
--- a/src/test/regress/sql/transactions.sql
+++ b/src/test/regress/sql/transactions.sql
@@ -290,3 +290,38 @@ ROLLBACK;
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;