sl@0: # 2005 july 8 sl@0: # sl@0: # The author disclaims copyright to this source code. In place of sl@0: # a legal notice, here is a blessing: sl@0: # sl@0: # May you do good and not evil. sl@0: # May you find forgiveness for yourself and forgive others. sl@0: # May you share freely, never taking more than you give. sl@0: # sl@0: #*********************************************************************** sl@0: # This file test the busy handler sl@0: # sl@0: # $Id: busy.test,v 1.3 2008/03/15 02:09:22 drh Exp $ sl@0: sl@0: sl@0: set testdir [file dirname $argv0] sl@0: source $testdir/tester.tcl sl@0: sl@0: do_test busy-1.1 { sl@0: sqlite3 db2 test.db sl@0: execsql { sl@0: CREATE TABLE t1(x); sl@0: INSERT INTO t1 VALUES(1); sl@0: SELECT * FROM t1 sl@0: } sl@0: } 1 sl@0: proc busy x { sl@0: lappend ::busyargs $x sl@0: if {$x>2} {return 1} sl@0: return 0 sl@0: } sl@0: set busyargs {} sl@0: do_test busy-1.2 { sl@0: db busy busy sl@0: db2 eval {BEGIN EXCLUSIVE} sl@0: catchsql {BEGIN IMMEDIATE} sl@0: } {1 {database is locked}} sl@0: do_test busy-1.3 { sl@0: set busyargs sl@0: } {0 1 2 3} sl@0: do_test busy-1.4 { sl@0: set busyargs {} sl@0: catchsql {BEGIN IMMEDIATE} sl@0: set busyargs sl@0: } {0 1 2 3} sl@0: sl@0: do_test busy-2.1 { sl@0: db2 eval {COMMIT} sl@0: db eval {BEGIN; INSERT INTO t1 VALUES(5)} sl@0: db2 eval {BEGIN; SELECT * FROM t1} sl@0: set busyargs {} sl@0: catchsql COMMIT sl@0: } {1 {database is locked}} sl@0: do_test busy-2.2 { sl@0: set busyargs sl@0: } {0 1 2 3} sl@0: sl@0: sl@0: db2 close sl@0: sl@0: finish_test