3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
6 # May you do good and not evil.
7 # May you find forgiveness for yourself and forgive others.
8 # May you share freely, never taking more than you give.
10 #***********************************************************************
12 # $Id: sharedlock.test,v 1.1 2009/07/02 17:21:58 danielk1977 Exp $
14 set testdir [file dirname $argv0]
15 source $testdir/tester.tcl
18 ifcapable !shared_cache {
23 set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
27 do_test sharedlock-1.1 {
29 CREATE TABLE t1(a, b);
30 INSERT INTO t1 VALUES(1, 'one');
31 INSERT INTO t1 VALUES(2, 'two');
35 do_test sharedlock-1.2 {
37 db eval { SELECT * FROM t1 ORDER BY rowid } {
39 if {$a == 1} { catch { db eval "INSERT INTO t1 VALUES(3, 'three')" } }
41 # This should fail. Connection [db] has a read-lock on t1, which should
42 # prevent connection [db2] from obtaining the write-lock it needs to
43 # modify t1. At one point there was a bug causing the previous INSERT
44 # to drop the read-lock belonging to [db].
45 if {$a == 2} { catch { db2 eval "INSERT INTO t1 VALUES(4, 'four')" } }
48 } {1 one 2 two 3 three}
53 sqlite3_enable_shared_cache $::enable_shared_cache