diff options
author | Hans-Christoph Steiner <hans@eds.org> | 2012-03-30 20:42:12 -0400 |
---|---|---|
committer | Hans-Christoph Steiner <hans@eds.org> | 2012-03-30 20:42:12 -0400 |
commit | 7bb481fda9ecb134804b49c2ce77ca28f7eea583 (patch) | |
tree | 31b520b9914d3e2453968abe375f2c102772c3dc /test/attach4.test |
Imported Upstream version 2.0.3
Diffstat (limited to 'test/attach4.test')
-rw-r--r-- | test/attach4.test | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/test/attach4.test b/test/attach4.test new file mode 100644 index 0000000..77dd7e4 --- /dev/null +++ b/test/attach4.test @@ -0,0 +1,118 @@ +# 200 July 1 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# 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. +# +#*********************************************************************** +# This file implements regression tests for SQLite library. The +# focus of this script is attaching many database files to a single +# connection. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +set testprefix attach4 + +ifcapable !attach { + finish_test + return +} + +puts "Testing with SQLITE_MAX_ATTACHED=$SQLITE_MAX_ATTACHED" + +set files {main test.db} +for {set ii 0} {$ii < $SQLITE_MAX_ATTACHED} {incr ii} { + lappend files aux$ii "test.db$ii" +} + +do_test 1.1 { + sqlite3_limit db SQLITE_LIMIT_ATTACHED -1 +} $SQLITE_MAX_ATTACHED + +do_test 1.2.1 { + db close + foreach {name f} $files { forcedelete $f } + sqlite3 db test.db + + foreach {name f} $files { + if {$name == "main"} continue + execsql "ATTACH '$f' AS $name" + } + + db eval {PRAGMA database_list} { + lappend L $name [file tail $file] + } + set L +} $files + +do_catchsql_test 1.2.2 { + ATTACH 'x.db' AS next; +} [list 1 "too many attached databases - max $SQLITE_MAX_ATTACHED"] + +do_test 1.3 { + execsql BEGIN; + foreach {name f} $files { + execsql "CREATE TABLE $name.tbl(x)" + execsql "INSERT INTO $name.tbl VALUES('$f')" + } + execsql COMMIT; +} {} + +do_test 1.4 { + set L [list] + foreach {name f} $files { + lappend L $name [execsql "SELECT x FROM $name.tbl"] + } + set L +} $files + +set L [list] +set S "" +foreach {name f} $files { + if {[permutation] == "journaltest"} { + set mode delete + } else { + set mode wal + } + ifcapable !wal { set mode delete } + lappend L $mode + append S " + PRAGMA $name.journal_mode = WAL; + UPDATE $name.tbl SET x = '$name'; + " +} +do_execsql_test 1.5 $S $L + +do_test 1.6 { + set L [list] + foreach {name f} $files { + lappend L [execsql "SELECT x FROM $name.tbl"] $f + } + set L +} $files + +do_test 1.7 { + execsql BEGIN; + foreach {name f} $files { + execsql "UPDATE $name.tbl SET x = '$f'" + } + execsql COMMIT; +} {} + +do_test 1.8 { + set L [list] + foreach {name f} $files { + lappend L $name [execsql "SELECT x FROM $name.tbl"] + } + set L +} $files + +db close +foreach {name f} $files { forcedelete $f } + +finish_test |