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