Annotation of embedaddon/sqlite3/test/attach4.test, revision 1.1.1.1
1.1 misho 1: # 200 July 1
2: #
3: # The author disclaims copyright to this source code. In place of
4: # a legal notice, here is a blessing:
5: #
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.
9: #
10: #***********************************************************************
11: # This file implements regression tests for SQLite library. The
12: # focus of this script is attaching many database files to a single
13: # connection.
14: #
15:
16: set testdir [file dirname $argv0]
17: source $testdir/tester.tcl
18:
19: set testprefix attach4
20:
21: ifcapable !attach {
22: finish_test
23: return
24: }
25:
26: puts "Testing with SQLITE_MAX_ATTACHED=$SQLITE_MAX_ATTACHED"
27:
28: set files {main test.db}
29: for {set ii 0} {$ii < $SQLITE_MAX_ATTACHED} {incr ii} {
30: lappend files aux$ii "test.db$ii"
31: }
32:
33: do_test 1.1 {
34: sqlite3_limit db SQLITE_LIMIT_ATTACHED -1
35: } $SQLITE_MAX_ATTACHED
36:
37: do_test 1.2.1 {
38: db close
39: foreach {name f} $files { forcedelete $f }
40: sqlite3 db test.db
41:
42: foreach {name f} $files {
43: if {$name == "main"} continue
44: execsql "ATTACH '$f' AS $name"
45: }
46:
47: db eval {PRAGMA database_list} {
48: lappend L $name [file tail $file]
49: }
50: set L
51: } $files
52:
53: do_catchsql_test 1.2.2 {
54: ATTACH 'x.db' AS next;
55: } [list 1 "too many attached databases - max $SQLITE_MAX_ATTACHED"]
56:
57: do_test 1.3 {
58: execsql BEGIN;
59: foreach {name f} $files {
60: execsql "CREATE TABLE $name.tbl(x)"
61: execsql "INSERT INTO $name.tbl VALUES('$f')"
62: }
63: execsql COMMIT;
64: } {}
65:
66: do_test 1.4 {
67: set L [list]
68: foreach {name f} $files {
69: lappend L $name [execsql "SELECT x FROM $name.tbl"]
70: }
71: set L
72: } $files
73:
74: set L [list]
75: set S ""
76: foreach {name f} $files {
77: if {[permutation] == "journaltest"} {
78: set mode delete
79: } else {
80: set mode wal
81: }
82: ifcapable !wal { set mode delete }
83: lappend L $mode
84: append S "
85: PRAGMA $name.journal_mode = WAL;
86: UPDATE $name.tbl SET x = '$name';
87: "
88: }
89: do_execsql_test 1.5 $S $L
90:
91: do_test 1.6 {
92: set L [list]
93: foreach {name f} $files {
94: lappend L [execsql "SELECT x FROM $name.tbl"] $f
95: }
96: set L
97: } $files
98:
99: do_test 1.7 {
100: execsql BEGIN;
101: foreach {name f} $files {
102: execsql "UPDATE $name.tbl SET x = '$f'"
103: }
104: execsql COMMIT;
105: } {}
106:
107: do_test 1.8 {
108: set L [list]
109: foreach {name f} $files {
110: lappend L $name [execsql "SELECT x FROM $name.tbl"]
111: }
112: set L
113: } $files
114:
115: db close
116: foreach {name f} $files { forcedelete $f }
117:
118: finish_test
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>