1# 2009 July 19
2#
3#    May you do good and not evil.
4#    May you find forgiveness for yourself and forgive others.
5#    May you share freely, never taking more than you give.
6#
7#***********************************************************************
8# This file tests that asynchronous IO is compatible with multi-file
9# transactions.
10#
11# $Id: async5.test,v 1.1 2009/07/18 11:52:04 danielk1977 Exp $
12
13set testdir [file dirname $argv0]
14source $testdir/tester.tcl
15
16if {[info commands sqlite3async_initialize] eq ""} {
17  # The async logic is not built into this system
18  finish_test
19  return
20}
21
22db close
23file delete -force test2.db
24sqlite3async_initialize "" 1
25sqlite3async_control halt never
26sqlite3 db test.db
27
28do_test async5-1.1 {
29  execsql {
30    ATTACH 'test2.db' AS next;
31    CREATE TABLE main.t1(a, b);
32    CREATE TABLE next.t2(a, b);
33    BEGIN;
34      INSERT INTO t1 VALUES(1, 2);
35      INSERT INTO t2 VALUES(3, 4);
36    COMMIT;
37  }
38} {}
39do_test async5-1.2 {
40  execsql { SELECT * FROM t1 }
41} {1 2}
42do_test async5-1.3 {
43  execsql { SELECT * FROM t2 }
44} {3 4}
45do_test async5-1.4 {
46  execsql {
47    BEGIN;
48      INSERT INTO t1 VALUES('a', 'b');
49      INSERT INTO t2 VALUES('c', 'd');
50    COMMIT;
51  }
52} {}
53do_test async5-1.5 {
54  execsql { SELECT * FROM t1 }
55} {1 2 a b}
56do_test async5-1.6 {
57  execsql { SELECT * FROM t2 }
58} {3 4 c d}
59
60db close
61
62sqlite3async_control halt idle
63sqlite3async_start
64sqlite3async_wait
65sqlite3async_control halt never
66sqlite3async_shutdown
67set sqlite3async_trace 0
68finish_test
69
70