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 18set testdir [file dirname $argv0] 19source $testdir/tester.tcl 20 21do_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 32do_test lock7-1.2 { 33 execsql { PRAGMA lock_status } db1 34} {main unlocked temp closed} 35do_test lock7-1.3 { 36 execsql { PRAGMA lock_status } db2 37} {main unlocked temp closed} 38 39do_test lock7-1.4 { 40 catchsql { INSERT INTO t1 VALUES(1, 1) } db1 41} {0 {}} 42do_test lock7-1.5 { 43 catchsql { INSERT INTO t1 VALUES(2, 2) } db2 44} {1 {database is locked}} 45 46do_test lock7-1.6 { 47 execsql { PRAGMA lock_status } db1 48} {main reserved temp closed} 49do_test lock7-1.7 { 50 execsql { PRAGMA lock_status } db2 51} {main unlocked temp closed} 52 53do_test lock7-1.8 { 54 execsql { COMMIT } db1 55} {} 56 57db1 close 58db2 close 59 60finish_test 61 62