1# 2# May you do good and not evil. 3# May you find forgiveness for yourself and forgive others. 4# May you share freely, never taking more than you give. 5# 6#*********************************************************************** 7# 8# $Id: async2.test,v 1.2 2006/02/14 13:48:34 danielk1977 Exp $ 9 10 11if {[info commands sqlite3async_enable]==""} { 12 # The async logic is not built into this system 13 return 14} 15 16set testdir [file dirname $argv0] 17source $testdir/tester.tcl 18 19# Enable asynchronous IO. 20 21set setup_script { 22 CREATE TABLE counter(c); 23 INSERT INTO counter(c) VALUES (1); 24} 25 26set sql_script { 27 BEGIN; 28 UPDATE counter SET c = 2; 29 CREATE TABLE t1(a PRIMARY KEY, b, c); 30 CREATE TABLE t2(a PRIMARY KEY, b, c); 31 COMMIT; 32 33 BEGIN; 34 UPDATE counter SET c = 3; 35 INSERT INTO t1 VALUES('abcdefghij', 'four', 'score'); 36 INSERT INTO t2 VALUES('klmnopqrst', 'and', 'seven'); 37 COMMIT; 38 39 UPDATE counter SET c = 'FIN'; 40} 41 42db close 43 44set ::go 1 45for {set n 3} {$::go} {incr n} { 46 set ::sqlite_io_error_pending 0 47 file delete -force test.db test.db-journal 48 sqlite3 db test.db 49 execsql $::setup_script 50 db close 51 52 sqlite3async_enable 1 53 sqlite3 db test.db 54 execsql $::sql_script 55 db close 56 57 set ::sqlite_io_error_pending $n 58 sqlite3async_halt idle 59 sqlite3async_start 60 sqlite3async_wait 61 62 set ::sqlite_io_error_pending 0 63 sqlite3 db test.db 64 set c [db eval {SELECT c FROM counter LIMIT 1}] 65 switch -- $c { 66 1 { 67 do_test async-ioerr-1.1.$n { 68 execsql { 69 SELECT name FROM sqlite_master; 70 } 71 } {counter} 72 } 73 2 { 74 do_test async-ioerr-1.2.$n.1 { 75 execsql { 76 SELECT * FROM t1; 77 } 78 } {} 79 do_test async-ioerr-1.2.$n.2 { 80 execsql { 81 SELECT * FROM t2; 82 } 83 } {} 84 } 85 3 { 86 do_test async-ioerr-1.3.$n.1 { 87 execsql { 88 SELECT * FROM t1; 89 } 90 } {abcdefghij four score} 91 do_test async-ioerr-1.3.$n.2 { 92 execsql { 93 SELECT * FROM t2; 94 } 95 } {klmnopqrst and seven} 96 } 97 FIN { 98 set ::go 0 99 } 100 } 101 102 sqlite3async_enable 0 103} 104 105catch {db close} 106sqlite3async_halt idle 107sqlite3async_start 108sqlite3async_wait 109 110finish_test 111