3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
12 # $Id: async4.test,v 1.4 2009/06/05 17:09:12 drh Exp $
14 set testdir [file dirname $argv0]
15 source $testdir/tester.tcl
17 # Do not use a codec for tests in this file, as the database file is
18 # manipulated directly using tcl scripts (using the [hexio_write] command).
22 # These tests only work for Tcl version 8.5 and later on Windows (for now)
24 if {$tcl_platform(platform)=="windows"} {
25 scan $::tcl_version %f vx
32 if {[info commands sqlite3async_initialize] eq ""} {
33 # The async logic is not built into this system
41 # async4.1.*: Test the lockfiles parameter.
42 # async4.2.*: Test the delay parameter.
45 sqlite3async_initialize {} 0
46 sqlite3async_control lockfiles
49 sqlite3async_control lockfiles false
52 sqlite3async_control lockfiles
55 sqlite3async_control lockfiles true
59 sqlite3 db test.db -vfs sqlite3async
60 execsql { CREATE TABLE t1(a, b, c) }
63 list [file exists test.db] [file size test.db]
67 catchsql { CREATE TABLE t2(a, b, c) } db2
68 } {1 {database is locked}}
70 sqlite3async_control halt idle
75 catchsql { CREATE TABLE t2(a, b, c) } db2
78 list [catch {sqlite3async_control lockfiles false} msg] $msg
82 list [catch {sqlite3async_control lockfiles false} msg] $msg
87 sqlite3async_control lockfiles false
90 sqlite3 db test.db -vfs sqlite3async
91 execsql { CREATE TABLE t3(a, b, c) } db
95 CREATE INDEX i1 ON t2(a);
96 CREATE INDEX i2 ON t1(a);
102 hexio_write test.db 28 00000000
103 execsql { pragma integrity_check } db2
104 } {{*** in database main ***
105 Page 5 is never used}}
106 do_test async4.1.16 {
112 do_test async4.1.17 {
113 sqlite3async_control lockfiles true
117 sqlite3async_control delay
120 sqlite3async_control delay 23
123 sqlite3async_control delay
126 sqlite3async_control delay 0
129 sqlite3 db test.db -vfs sqlite3async
131 execsql { CREATE TABLE t4(a, b) }
132 set T1 [lindex [time {
137 sqlite3async_control delay 100
138 execsql { CREATE TABLE t5(a, b) }
139 set T2 [lindex [time {
144 expr {($T1+1000000) < $T2}
148 sqlite3async_control delay 0
149 execsql { CREATE TABLE t6(a, b) }
150 set T1 [lindex [time {
155 expr {($T1+1000000) < $T2}
159 list [catch { sqlite3async_control delay -1 } msg] $msg