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 #***********************************************************************
11 # This file implements regression tests for SQLite library. The
12 # focus of this script is attaching many database files to a single
16 set testdir [file dirname $argv0]
17 source $testdir/tester.tcl
19 set testprefix attach4
26 puts "Testing with SQLITE_MAX_ATTACHED=$SQLITE_MAX_ATTACHED"
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"
34 sqlite3_limit db SQLITE_LIMIT_ATTACHED -1
35 } $SQLITE_MAX_ATTACHED
39 foreach {name f} $files { forcedelete $f }
42 foreach {name f} $files {
43 if {$name == "main"} continue
44 execsql "ATTACH '$f' AS $name"
47 db eval {PRAGMA database_list} {
48 lappend L $name [file tail $file]
53 do_catchsql_test 1.2.2 {
54 ATTACH 'x.db' AS next;
55 } [list 1 "too many attached databases - max $SQLITE_MAX_ATTACHED"]
59 foreach {name f} $files {
60 execsql "CREATE TABLE $name.tbl(x)"
61 execsql "INSERT INTO $name.tbl VALUES('$f')"
68 foreach {name f} $files {
69 lappend L $name [execsql "SELECT x FROM $name.tbl"]
76 foreach {name f} $files {
77 if {[permutation] == "journaltest"} {
82 ifcapable !wal { set mode delete }
85 PRAGMA $name.journal_mode = WAL;
86 UPDATE $name.tbl SET x = '$name';
89 do_execsql_test 1.5 $S $L
93 foreach {name f} $files {
94 lappend L [execsql "SELECT x FROM $name.tbl"] $f
101 foreach {name f} $files {
102 execsql "UPDATE $name.tbl SET x = '$f'"
109 foreach {name f} $files {
110 lappend L $name [execsql "SELECT x FROM $name.tbl"]
116 foreach {name f} $files { forcedelete $f }
118 #-------------------------------------------------------------------------
120 do_execsql_test 2.0 {
121 ATTACH DATABASE '' AS aux;
122 CREATE TABLE IF NOT EXISTS aux.t1(a, b);
123 CREATE TEMPORARY TRIGGER tr1 DELETE ON t1 BEGIN
126 CREATE TABLE temp.t1(a, b);
129 do_execsql_test 2.1 {
133 do_execsql_test 2.2 {