]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add some tests with attached databases to savepoint.test. Also tests of creating...
authordanielk1977 <danielk1977@noemail.net>
Sat, 3 Jan 2009 15:06:38 +0000 (15:06 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Sat, 3 Jan 2009 15:06:38 +0000 (15:06 +0000)
FossilOrigin-Name: ca7f11d50d1a73443d18c79dfe4223c975c6e20b

manifest
manifest.uuid
test/permutations.test
test/savepoint.test

index 581acee2b898ced37f99b1bc75f454191391fa86..eb38eedc32f998c1cf55c59fe9799d5c80ed2f1c 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C When\sthe\scommit_hook\scalls\sa\squery\srecursively,\smake\ssure\sthe\scommit_hook\nis\snot\sinvoked\srecursively.\s\sTicket\s#3564.\s(CVS\s6107)
-D 2009-01-03T14:04:39
+C Add\ssome\stests\swith\sattached\sdatabases\sto\ssavepoint.test.\sAlso\stests\sof\screating\sand\sdropping\stables\sin\sauto-vacuum\smode\sinside\sof\sa\ssavepoint.\s(CVS\s6108)
+D 2009-01-03T15:06:38
 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
 F Makefile.in 05461a9b5803d5ad10c79f989801e9fd2cc3e592
 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -477,7 +477,7 @@ F test/pageropt.test 3ee6578891baaca967f0bd349e4abfa736229e1a
 F test/pagesize.test 0d9ff3fedfce6e5ffe8fa7aca9b6d3433a2e843b
 F test/pcache.test 515b4c26e9f57660357dfff5b6b697acac1abc5f
 F test/pcache2.test 46efd980a89f737847b99327bda19e08fe11e402
-F test/permutations.test 4d1546196eeb642611514f68d074c6e779466973
+F test/permutations.test dccfc24254ab8d9cb9098e790c12fae52865f65f
 F test/pragma.test 325aa0833d483b8e0c98e8196f1cc49fa5d8c336
 F test/pragma2.test 5364893491b9231dd170e3459bfc2e2342658b47
 F test/printf.test 262a5acd3158f788e9bdf7f18d718f3af32ff6ef
@@ -493,7 +493,7 @@ F test/rollback.test 1f70ab4301d8d105d41438a436cad1fc8897f5e5
 F test/rowid.test 1c8fc43c60d273e6ea44dfb992db587f3164312c
 F test/rtree.test b85fd4f0861a40ca366ac195e363be2528dcfadf
 F test/safety.test b69e2b2dd5d52a3f78e216967086884bbc1a09c6
-F test/savepoint.test 08803877993d11cfbe3bbbaf811822e068a2dd8b
+F test/savepoint.test 154001ac2863714eadd9c79865fa07faeda3d3a4
 F test/savepoint2.test 18f6c75d5c133b93838019df8988b8cdf379d3de
 F test/savepoint3.test 1a0b1c0f59c6ae4402bfbca7cec29d4b1b272ff0
 F test/savepoint4.test fd8850063e3c40565545f5c291e7f79a30591670
@@ -692,7 +692,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
 F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
-P 50f57cd1456f18919a8c90efa05da446ae12788d
-R 7224ef793d5f6387bd34cf62f3dc2850
-U drh
-Z 4f061edd82220a513e722f7b8cfb9dc6
+P 27ae406537c07073db46ecde40c65c78fbb73170
+R f1261b4aaf79058f39badb22de0f89d4
+U danielk1977
+Z 89a8f6d28c2f24e84f9c102fa36950dc
index 2d7d1f5483542c0b57e28511c152107d5de7a7a7..6cac826953600b0529c0e8a7dc47832223368f04 100644 (file)
@@ -1 +1 @@
-27ae406537c07073db46ecde40c65c78fbb73170
\ No newline at end of file
+ca7f11d50d1a73443d18c79dfe4223c975c6e20b
\ No newline at end of file
index 178ca01cd0ebf3da0b5afe2f46740345edb0508d..2599c2d586641e19b4a7340716394de8aef58bc7 100644 (file)
@@ -9,7 +9,7 @@
 #
 #***********************************************************************
 #
-# $Id: permutations.test,v 1.41 2008/12/30 13:21:51 danielk1977 Exp $
+# $Id: permutations.test,v 1.42 2009/01/03 15:06:38 danielk1977 Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -72,6 +72,7 @@ set EXCLUDE {
   fuzz_malloc.test          misuse.test               veryquick.test
   fuzz.test                 mutex2.test               vtab_err.test
   lookaside.test            fuzz3.test                savepoint4.test
+  savepoint6.test
 }
 set ALLTESTS [list]
 foreach filename [glob $testdir/*.test] {
@@ -713,12 +714,13 @@ run_tests "journaltest" -description {
   register_jt_vfs -default ""
 } -shutdown {
   unregister_jt_vfs
-} -exclude [concat $EXCLUDE {
+} -include [concat $::ALLTESTS savepoint6.test
+] -exclude {
   incrvacuum.test
   ioerr.test
   corrupt4.test 
   io.test 
-}]
+}
 
 # End of tests
 #############################################################################
index 126d9746cc7d4187735596ee4cdb590353d21b3e..b79c87f572474c79fc152e5ba1f6adcbd9eec883 100644 (file)
@@ -9,7 +9,7 @@
 #
 #***********************************************************************
 #
-# $Id: savepoint.test,v 1.6 2009/01/01 14:06:13 danielk1977 Exp $
+# $Id: savepoint.test,v 1.7 2009/01/03 15:06:38 danielk1977 Exp $
 
 set testdir [file dirname $argv0]
 source $testdir/tester.tcl
@@ -524,8 +524,197 @@ ifcapable auth {
     set res [catchsql { RELEASE sp1 }]
     concat $::authdata $res
   } {SQLITE_SAVEPOINT RELEASE sp1 {} {} 1 {not authorized}}
+
+  catch { db eval ROLLBACK }
+  db auth ""
 }
 
+#-------------------------------------------------------------------------
+# The following tests - savepoint-10.* - test the interaction of 
+# savepoints and ATTACH statements.
+# 
+
+# First make sure it is not possible to attach or detach a database while
+# a savepoint is open (it is not possible if any transaction is open).
+#
+do_test savepoint-10.1.1 {
+  catchsql {
+    SAVEPOINT one;
+    ATTACH 'test2.db' AS aux;
+  }
+} {1 {cannot ATTACH database within transaction}}
+do_test savepoint-10.1.2 {
+  execsql {
+    RELEASE one;
+    ATTACH 'test2.db' AS aux;
+  }
+  catchsql {
+    SAVEPOINT one;
+    DETACH aux;
+  }
+} {1 {cannot DETACH database within transaction}}
+do_test savepoint-10.1.3 {
+  execsql {
+    RELEASE one;
+    DETACH aux;
+  }
+} {}
+
+do_test savepoint-10.2.1 {
+  file delete -force test3.db
+  file delete -force test2.db
+  execsql {
+    ATTACH 'test2.db' AS aux1;
+    ATTACH 'test3.db' AS aux2;
+    DROP TABLE t1;
+    CREATE TABLE main.t1(x, y);
+    CREATE TABLE aux1.t2(x, y);
+    CREATE TABLE aux2.t3(x, y);
+    SELECT name FROM sqlite_master 
+      UNION ALL
+    SELECT name FROM aux1.sqlite_master 
+      UNION ALL
+    SELECT name FROM aux2.sqlite_master;
+  }
+} {t1 t2 t3}
+do_test savepoint-10.2.2 {
+  execsql { PRAGMA lock_status }
+} {main unlocked temp unlocked aux1 unlocked aux2 unlocked}
+
+do_test savepoint-10.2.3 {
+  execsql {
+    SAVEPOINT one;
+    INSERT INTO t1 VALUES(1, 2);
+    PRAGMA lock_status;
+  }
+} {main reserved temp unlocked aux1 unlocked aux2 unlocked}
+do_test savepoint-10.2.4 {
+  execsql {
+    INSERT INTO t3 VALUES(3, 4);
+    PRAGMA lock_status;
+  }
+} {main reserved temp unlocked aux1 unlocked aux2 reserved}
+do_test savepoint-10.2.5 {
+  execsql {
+    SAVEPOINT two;
+    INSERT INTO t2 VALUES(5, 6);
+    PRAGMA lock_status;
+  }
+} {main reserved temp unlocked aux1 reserved aux2 reserved}
+do_test savepoint-10.2.6 {
+  execsql { SELECT * FROM t2 }
+} {5 6}
+do_test savepoint-10.2.7 {
+  execsql { ROLLBACK TO two }
+  execsql { SELECT * FROM t2 }
+} {}
+do_test savepoint-10.2.8 {
+  execsql { PRAGMA lock_status }
+} {main reserved temp unlocked aux1 reserved aux2 reserved}
+do_test savepoint-10.2.9 {
+  execsql { SELECT 'a', * FROM t1 UNION ALL SELECT 'b', * FROM t3 }
+} {a 1 2 b 3 4}
+do_test savepoint-10.2.9 {
+  execsql {
+    INSERT INTO t2 VALUES(5, 6);
+    RELEASE one;
+  }
+  execsql { 
+    SELECT * FROM t1;
+    SELECT * FROM t2;
+    SELECT * FROM t3;
+  }
+} {1 2 5 6 3 4}
+do_test savepoint-10.2.9 {
+  execsql { PRAGMA lock_status }
+} {main unlocked temp unlocked aux1 unlocked aux2 unlocked}
+
+do_test savepoint-10.2.10 {
+  execsql { 
+    SAVEPOINT one;
+      INSERT INTO t1 VALUES('a', 'b');
+      SAVEPOINT two;
+        INSERT INTO t2 VALUES('c', 'd');
+        SAVEPOINT three;
+          INSERT INTO t3 VALUES('e', 'f');
+  }
+  execsql { 
+    SELECT * FROM t1;
+    SELECT * FROM t2;
+    SELECT * FROM t3;
+  }
+} {1 2 a b 5 6 c d 3 4 e f}
+do_test savepoint-10.2.11 {
+  execsql { ROLLBACK TO two }
+  execsql { 
+    SELECT * FROM t1;
+    SELECT * FROM t2;
+    SELECT * FROM t3;
+  }
+} {1 2 a b 5 6 3 4}
+do_test savepoint-10.2.12 {
+  execsql { 
+    INSERT INTO t3 VALUES('g', 'h');
+    ROLLBACK TO two;
+  }
+  execsql { 
+    SELECT * FROM t1;
+    SELECT * FROM t2;
+    SELECT * FROM t3;
+  }
+} {1 2 a b 5 6 3 4}
+do_test savepoint-10.2.13 {
+  execsql { ROLLBACK }
+  execsql { 
+    SELECT * FROM t1;
+    SELECT * FROM t2;
+    SELECT * FROM t3;
+  }
+} {1 2 5 6 3 4}
+do_test savepoint-10.2.14 {
+  execsql { PRAGMA lock_status }
+} {main unlocked temp unlocked aux1 unlocked aux2 unlocked}
+
+#-------------------------------------------------------------------------
+# The following tests - savepoint-11.* - test the interaction of 
+# savepoints and creating or dropping tables and indexes in 
+# auto-vacuum mode.
+# 
+do_test savepoint-11.1 {
+  db close
+  file delete -force test.db
+  sqlite3 db test.db
+  execsql {
+    PRAGMA auto_vacuum = full;
+    CREATE TABLE t1(a, b, UNIQUE(a, b));
+    INSERT INTO t1 VALUES(1, randstr(1000,1000));
+    INSERT INTO t1 VALUES(2, randstr(1000,1000));
+  }
+} {}
+do_test savepoint-11.2 {
+  execsql {
+    SAVEPOINT one;
+      CREATE TABLE t2(a, b, UNIQUE(a, b));
+      SAVEPOINT two;
+        CREATE TABLE t3(a, b, UNIQUE(a, b));
+  }
+} {}
+integrity_check savepoint-11.3
+do_test savepoint-11.4 {
+  execsql { ROLLBACK TO two }
+} {}
+integrity_check savepoint-11.5
+do_test savepoint-11.6 {
+  execsql { 
+    CREATE TABLE t3(a, b, UNIQUE(a, b));
+    ROLLBACK TO one;
+  }
+} {}
+integrity_check savepoint-11.7
+do_test savepoint-11.6 {
+  execsql { ROLLBACK }
+  file size test.db
+} {8192}
 
 finish_test