summaryrefslogtreecommitdiff
path: root/test/savepoint7.test
diff options
context:
space:
mode:
authorHans-Christoph Steiner <hans@eds.org>2012-09-20 18:34:38 -0400
committerHans-Christoph Steiner <hans@eds.org>2012-09-20 18:34:38 -0400
commit487e15dc239ccdb3344d1c99ce120e872bab4a74 (patch)
treec986d492f6092ca7b4401d91515f74daed17fae2 /test/savepoint7.test
parent7bb481fda9ecb134804b49c2ce77ca28f7eea583 (diff)
Imported Upstream version 2.0.6
Diffstat (limited to 'test/savepoint7.test')
-rw-r--r--test/savepoint7.test96
1 files changed, 96 insertions, 0 deletions
diff --git a/test/savepoint7.test b/test/savepoint7.test
new file mode 100644
index 0000000..bc99187
--- /dev/null
+++ b/test/savepoint7.test
@@ -0,0 +1,96 @@
+# 2012 March 31
+#
+# The author disclaims copyright to this source code. In place of
+# a legal notice, here is a blessing:
+#
+# May you do good and not evil.
+# May you find forgiveness for yourself and forgive others.
+# May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Focus on the interaction between RELEASE and ROLLBACK TO with
+# pending query aborts. See ticket [27ca74af3c083f787a1c44b11fbb7c53bdbbcf1e].
+#
+
+set testdir [file dirname $argv0]
+source $testdir/tester.tcl
+
+# The RELEASE of an inner savepoint should not effect pending queries.
+#
+do_test savepoint7-1.1 {
+ db eval {
+ CREATE TABLE t1(a,b,c);
+ CREATE TABLE t2(x,y,z);
+ INSERT INTO t1 VALUES(1,2,3);
+ INSERT INTO t1 VALUES(4,5,6);
+ INSERT INTO t1 VALUES(7,8,9);
+ SAVEPOINT x1;
+ }
+ db eval {SELECT * FROM t1} {
+ db eval {
+ SAVEPOINT x2;
+ INSERT INTO t2 VALUES($a,$b,$c);
+ RELEASE x2;
+ }
+ }
+ db eval {SELECT * FROM t2; RELEASE x1}
+} {1 2 3 4 5 6 7 8 9}
+
+do_test savepoint7-1.2 {
+ db eval {DELETE FROM t2;}
+ db eval {SELECT * FROM t1} {
+ db eval {
+ SAVEPOINT x2;
+ INSERT INTO t2 VALUES($a,$b,$c);
+ RELEASE x2;
+ }
+ }
+ db eval {SELECT * FROM t2}
+} {1 2 3 4 5 6 7 8 9}
+
+do_test savepoint7-1.3 {
+ db eval {DELETE FROM t2; BEGIN;}
+ db eval {SELECT * FROM t1} {
+ db eval {
+ SAVEPOINT x2;
+ INSERT INTO t2 VALUES($a,$b,$c);
+ RELEASE x2;
+ }
+ }
+ db eval {SELECT * FROM t2; ROLLBACK;}
+} {1 2 3 4 5 6 7 8 9}
+
+# However, a ROLLBACK of an inner savepoint will abort all queries, including
+# queries in outer contexts.
+#
+do_test savepoint7-2.1 {
+ db eval {DELETE FROM t2; SAVEPOINT x1;}
+ set rc [catch {
+ db eval {SELECT * FROM t1} {
+ db eval {
+ SAVEPOINT x2;
+ INSERT INTO t2 VALUES($a,$b,$c);
+ ROLLBACK TO x2;
+ }
+ }
+ } msg]
+ db eval {RELEASE x1}
+ list $rc $msg [db eval {SELECT * FROM t2}]
+} {1 {callback requested query abort} {}}
+
+do_test savepoint7-2.2 {
+ db eval {DELETE FROM t2;}
+ set rc [catch {
+ db eval {SELECT * FROM t1} {
+ db eval {
+ SAVEPOINT x2;
+ INSERT INTO t2 VALUES($a,$b,$c);
+ ROLLBACK TO x2;
+ }
+ }
+ } msg]
+ list $rc $msg [db eval {SELECT * FROM t2}]
+} {1 {callback requested query abort} {}}
+
+finish_test