os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/busy.test
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/persistentstorage/sqlite3api/TEST/TclScript/busy.test	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,61 @@
     1.4 +# 2005 july 8
     1.5 +#
     1.6 +# The author disclaims copyright to this source code.  In place of
     1.7 +# a legal notice, here is a blessing:
     1.8 +#
     1.9 +#    May you do good and not evil.
    1.10 +#    May you find forgiveness for yourself and forgive others.
    1.11 +#    May you share freely, never taking more than you give.
    1.12 +#
    1.13 +#***********************************************************************
    1.14 +# This file test the busy handler
    1.15 +#
    1.16 +# $Id: busy.test,v 1.3 2008/03/15 02:09:22 drh Exp $
    1.17 +
    1.18 +
    1.19 +set testdir [file dirname $argv0]
    1.20 +source $testdir/tester.tcl
    1.21 +
    1.22 +do_test busy-1.1 {
    1.23 +  sqlite3 db2 test.db
    1.24 +  execsql {
    1.25 +    CREATE TABLE t1(x);
    1.26 +    INSERT INTO t1 VALUES(1);
    1.27 +    SELECT * FROM t1
    1.28 +  }
    1.29 +} 1
    1.30 +proc busy x {
    1.31 +  lappend ::busyargs $x
    1.32 +  if {$x>2} {return 1}
    1.33 +  return 0
    1.34 +}
    1.35 +set busyargs {}
    1.36 +do_test busy-1.2 {
    1.37 +  db busy busy
    1.38 +  db2 eval {BEGIN EXCLUSIVE}
    1.39 +  catchsql {BEGIN IMMEDIATE}
    1.40 +} {1 {database is locked}}
    1.41 +do_test busy-1.3 {
    1.42 +  set busyargs
    1.43 +} {0 1 2 3}
    1.44 +do_test busy-1.4 {
    1.45 +  set busyargs {}
    1.46 +  catchsql {BEGIN IMMEDIATE}
    1.47 +  set busyargs
    1.48 +} {0 1 2 3}
    1.49 +
    1.50 +do_test busy-2.1 {
    1.51 +  db2 eval {COMMIT}
    1.52 +  db eval {BEGIN; INSERT INTO t1 VALUES(5)}
    1.53 +  db2 eval {BEGIN; SELECT * FROM t1}
    1.54 +  set busyargs {}
    1.55 +  catchsql COMMIT
    1.56 +} {1 {database is locked}}
    1.57 +do_test busy-2.2 {
    1.58 +  set busyargs
    1.59 +} {0 1 2 3}
    1.60 +
    1.61 +
    1.62 +db2 close
    1.63 +
    1.64 +finish_test