]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Some test cases for read locks (CVS 1505)
authordanielk1977 <danielk1977@noemail.net>
Mon, 31 May 2004 12:34:53 +0000 (12:34 +0000)
committerdanielk1977 <danielk1977@noemail.net>
Mon, 31 May 2004 12:34:53 +0000 (12:34 +0000)
FossilOrigin-Name: 0e07006704cd441f91d5fadbf3b644fd20da79bd

manifest
manifest.uuid
test/attach2.test

index 2b6df9ff58639c51d30d51b59fd360a1cb9988d1..c168ce953ecbbe1cb15a0725a3b00d45f8be05a6 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Use\sread-only\stransactions.\s(CVS\s1504)
-D 2004-05-31T11:51:45
+C Some\stest\scases\sfor\sread\slocks\s(CVS\s1505)
+D 2004-05-31T12:34:54
 F Makefile.in ab7b0d5118e2da97bac66be8684a1034e3500f5a
 F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
 F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
@@ -78,7 +78,7 @@ F src/vdbemem.c 627d714c347f6af8092cc48ae1c06fd774a1ad9c
 F src/where.c 444a7c3a8b1eb7bba072e489af628555d21d92a4
 F test/all.test 569a92a8ee88f5300c057cc4a8f50fbbc69a3242
 F test/attach.test cbc9c5286e614171a68da3f0b05ccba313fd4c5d
-F test/attach2.test 617583b73005638100721b4178c28d0b9df67494
+F test/attach2.test e98aab312722d05fc1837bf103baeebc582c64f8
 F test/attach3.test d384ac2e59f305743f73aec4b3d97b36fa5c6975
 F test/auth.test 95809b8f6a9bec18b94d28cafd03fe27d2f8a9e9
 F test/bigfile.test ea904b853ce2d703b16c5ce90e2b54951bc1ae81
@@ -204,7 +204,7 @@ F www/sqlite.tcl 3c83b08cf9f18aa2d69453ff441a36c40e431604
 F www/tclsqlite.tcl b9271d44dcf147a93c98f8ecf28c927307abd6da
 F www/vdbe.tcl 9b9095d4495f37697fd1935d10e14c6015e80aa1
 F www/whentouse.tcl a8335bce47cc2fddb07f19052cb0cb4d9129a8e4
-P 5f869fbfc029eb2601d1d967685517d007d002a4
-R 62350eb9f403c6ef305bb359dbc711d8
+P 6c100887eeb32631e1aa914a69db959e1f58f192
+R 1d8f5d0a6729c7e39d4d87422195d60b
 U danielk1977
-Z 89534b52ebf7a971be3266cc25c2b9c8
+Z 3129e3edc85b79121f4ae67280793a64
index a0b51b4d34d09bab4517fd4da245fcc800a8877a..beab512d5421f5a8e35be1d2e0dd5f47b93e8f3d 100644 (file)
@@ -1 +1 @@
-6c100887eeb32631e1aa914a69db959e1f58f192
\ No newline at end of file
+0e07006704cd441f91d5fadbf3b644fd20da79bd
\ No newline at end of file
index 9c79b33a04a9a5fc8a7ef0567beb044e02a4ef4e..599d23ef304270de0896ba53656aa332ebd8c2c2 100644 (file)
@@ -12,7 +12,7 @@
 # focus of this script is testing the ATTACH and DETACH commands
 # and related functionality.
 #
-# $Id: attach2.test,v 1.10 2004/05/31 08:26:49 danielk1977 Exp $
+# $Id: attach2.test,v 1.11 2004/05/31 12:34:54 danielk1977 Exp $
 #
 
 
@@ -146,7 +146,94 @@ db close
 for {set i 2} {$i<=15} {incr i} {
   catch {db$i close}
 }
-file delete -force test2.db
 
+# Tests attach2-4.* test that read-locks work correctly with attached
+# databases.
+do_test attach2-4.1 {
+  sqlite db test.db
+  sqlite db2 test.db
+  execsql {ATTACH 'test2.db' as file2}
+  execsql {ATTACH 'test2.db' as file2} db2
+} {}
+
+do_test attach2-4.2 {
+  # Handle 'db' read-locks the main file
+  execsql {BEGIN}
+  execsql {SELECT * FROM t1}
+} {}
+do_test attach2-4.3 {
+  execsql {SELECT * FROM t1} db2
+} {}
+do_test attach2-4.4 {
+  set r [catch { 
+    execsql {
+      INSERT INTO t1 VALUES(1, 2)
+    } db2 
+  } msg]
+  list $r $msg
+} {1 {database is locked}}
+do_test attach2-4.5 {
+  # Handle 'db2' write-locks file2
+  execsql {BEGIN} db2
+  execsql {INSERT INTO file2.t1 VALUES(1, 2)} db2
+} {}
+do_test attach2-4.6 {
+  set r [catch { 
+    execsql {
+      SELECT * FROM file2.t1;
+    } 
+  } msg]
+  list $r $msg
+} {1 {database is locked}}
+do_test attach2-4.7 {
+  # Ensure handle 'db' retains the lock on the main file after
+  # failing to obtain a read-lock on file2.
+  set r [catch { 
+    execsql {
+      INSERT INTO t1 VALUES(1, 2)
+    } db2 
+  } msg]
+  list $r $msg
+} {1 {database is locked}}
+do_test attach2-4.8 {
+  # Read lock the main file with db2. Now both handles have a read lock
+  # on the main file, db2 has a write-lock on file2.
+  execsql {SELECT * FROM t1} db2
+} {}
+do_test attach2-4.9 {
+  # Try to upgrade the handle 'db' lock.
+  set r [catch { 
+    execsql {
+      INSERT INTO t1 VALUES(1, 2)
+    } 
+  } msg]
+  list $r $msg
+} {1 {database is locked}}
+do_test attach2-4.10 {
+  # Release the locks held by handle 'db2'
+  execsql {COMMIT} db2
+} {}
+do_test attach2-4.11 {
+  execsql {SELECT * FROM file2.t1}
+} {1 2}
+do_test attach2-4.12 {
+  execsql {INSERT INTO t1 VALUES(1, 2)}
+} {}
+do_test attach2-4.13 {
+  # Release the locks held by handle 'db'
+  execsql {ROLLBACK}
+} {}
+do_test attach2-4.14 {
+  execsql {SELECT * FROM t1} db2
+} {}
+
+db close
+db2 close
+file delete -force test2.db
 
 finish_test
+
+
+
+
+