CoolFace
Modelpublic

AryaWu/sqlite

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
lock7.test61 linesDownload Raw Back to test
1# 2009 August 172#3# The author disclaims copyright to this source code.  In place of4# 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 transaction13# does not establish a SHARED lock on the database file if one is not14# already held (or, more accurately, that the SHARED lock is released after15# reading the database schema).16#17 18set testdir [file dirname $argv0]19source $testdir/tester.tcl20 21do_test lock7-1.1 {22  execsql { CREATE TABLE t1(a, b) }23  db close24 25  sqlite3 db1 test.db26  sqlite3 db2 test.db27 28  db1 eval {BEGIN}29  db2 eval {BEGIN}30} {}31 32do_test lock7-1.2 {33  execsql { PRAGMA lock_status } db134} {main unlocked temp closed}35do_test lock7-1.3 {36  execsql { PRAGMA lock_status } db237} {main unlocked temp closed}38 39do_test lock7-1.4 {40  catchsql { INSERT INTO t1 VALUES(1, 1) } db141} {0 {}}42do_test lock7-1.5 {43  catchsql { INSERT INTO t1 VALUES(2, 2) } db244} {1 {database is locked}}45 46do_test lock7-1.6 {47  execsql { PRAGMA lock_status } db148} {main reserved temp closed}49do_test lock7-1.7 {50  execsql { PRAGMA lock_status } db251} {main unlocked temp closed}52 53do_test lock7-1.8 {54  execsql { COMMIT } db155} {}56 57db1 close58db2 close59 60finish_test61