1*d768f944Sdan# 2009 August 17 2*d768f944Sdan# 3*d768f944Sdan# The author disclaims copyright to this source code. In place of 4*d768f944Sdan# a legal notice, here is a blessing: 5*d768f944Sdan# 6*d768f944Sdan# May you do good and not evil. 7*d768f944Sdan# May you find forgiveness for yourself and forgive others. 8*d768f944Sdan# May you share freely, never taking more than you give. 9*d768f944Sdan# 10*d768f944Sdan#*********************************************************************** 11*d768f944Sdan# 12*d768f944Sdan# Check that reading the database schema from within an active transaction 13*d768f944Sdan# does not establish a SHARED lock on the database file if one is not 14*d768f944Sdan# already held (or, more accurately, that the SHARED lock is released after 15*d768f944Sdan# reading the database schema). 16*d768f944Sdan# 17*d768f944Sdan 18*d768f944Sdanset testdir [file dirname $argv0] 19*d768f944Sdansource $testdir/tester.tcl 20*d768f944Sdan 21*d768f944Sdando_test lock7-1.1 { 22*d768f944Sdan execsql { CREATE TABLE t1(a, b) } 23*d768f944Sdan db close 24*d768f944Sdan 25*d768f944Sdan sqlite3 db1 test.db 26*d768f944Sdan sqlite3 db2 test.db 27*d768f944Sdan 28*d768f944Sdan db1 eval {BEGIN} 29*d768f944Sdan db2 eval {BEGIN} 30*d768f944Sdan} {} 31*d768f944Sdan 32*d768f944Sdando_test lock7-1.2 { 33*d768f944Sdan execsql { PRAGMA lock_status } db1 34*d768f944Sdan} {main unlocked temp closed} 35*d768f944Sdando_test lock7-1.3 { 36*d768f944Sdan execsql { PRAGMA lock_status } db2 37*d768f944Sdan} {main unlocked temp closed} 38*d768f944Sdan 39*d768f944Sdando_test lock7-1.4 { 40*d768f944Sdan catchsql { INSERT INTO t1 VALUES(1, 1) } db1 41*d768f944Sdan} {0 {}} 42*d768f944Sdando_test lock7-1.5 { 43*d768f944Sdan catchsql { INSERT INTO t1 VALUES(2, 2) } db2 44*d768f944Sdan} {1 {database is locked}} 45*d768f944Sdan 46*d768f944Sdando_test lock7-1.6 { 47*d768f944Sdan execsql { PRAGMA lock_status } db1 48*d768f944Sdan} {main reserved temp closed} 49*d768f944Sdando_test lock7-1.7 { 50*d768f944Sdan execsql { PRAGMA lock_status } db2 51*d768f944Sdan} {main unlocked temp closed} 52*d768f944Sdan 53*d768f944Sdando_test lock7-1.8 { 54*d768f944Sdan execsql { COMMIT } db1 55*d768f944Sdan} {} 56*d768f944Sdan 57*d768f944Sdandb1 close 58*d768f944Sdandb2 close 59*d768f944Sdan 60*d768f944Sdanfinish_test 61