Home | History | Annotate | Download | only in test
      1 # 2009 August 17
      2 #
      3 # The author disclaims copyright to this source code.  In place of
      4 # a legal notice, here is a blessing:
      5 #
      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.
      9 #
     10 #***********************************************************************
     11 #
     12 # Check that reading the database schema from within an active transaction
     13 # does not establish a SHARED lock on the database file if one is not
     14 # already held (or, more accurately, that the SHARED lock is released after
     15 # reading the database schema).
     16 #
     17 
     18 set testdir [file dirname $argv0]
     19 source $testdir/tester.tcl
     20 
     21 do_test lock7-1.1 {
     22   execsql { CREATE TABLE t1(a, b) }
     23   db close
     24 
     25   sqlite3 db1 test.db
     26   sqlite3 db2 test.db
     27 
     28   db1 eval {BEGIN}
     29   db2 eval {BEGIN}
     30 } {}
     31 
     32 do_test lock7-1.2 {
     33   execsql { PRAGMA lock_status } db1
     34 } {main unlocked temp closed}
     35 do_test lock7-1.3 {
     36   execsql { PRAGMA lock_status } db2
     37 } {main unlocked temp closed}
     38 
     39 do_test lock7-1.4 {
     40   catchsql { INSERT INTO t1 VALUES(1, 1) } db1
     41 } {0 {}}
     42 do_test lock7-1.5 {
     43   catchsql { INSERT INTO t1 VALUES(2, 2) } db2
     44 } {1 {database is locked}}
     45 
     46 do_test lock7-1.6 {
     47   execsql { PRAGMA lock_status } db1
     48 } {main reserved temp closed}
     49 do_test lock7-1.7 {
     50   execsql { PRAGMA lock_status } db2
     51 } {main unlocked temp closed}
     52 
     53 do_test lock7-1.8 {
     54   execsql { COMMIT } db1
     55 } {}
     56 
     57 db1 close
     58 db2 close
     59 
     60 finish_test
     61 
     62