2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A# The author disclaims copyright to this source code. In place of
2N/A# a legal notice, here is a blessing:
2N/A# May you do good and not evil.
2N/A# May you find forgiveness for yourself and forgive others.
2N/A# May you share freely, never taking more than you give.
2N/A#***********************************************************************
2N/A# This file implements regression tests for SQLite library. The
2N/A# focus of this script is testing the ATTACH and DETACH commands
2N/A# and related functionality.
2N/Aset testdir [file dirname $argv0]
2N/Ado_test attach2-1.1 {
2N/A CREATE TABLE t1(a,b);
2N/A CREATE INDEX x1 ON t1(a);
2N/A CREATE TABLE t1(a,b);
2N/A CREATE INDEX x1 ON t1(a);
2N/A foreach {idx name file} [execsql {PRAGMA database_list} $db] {
2N/A lappend list $idx $name
2N/Ado_test attach2-2.1 {
2N/A # lock
test2.db then try to attach it. Should get an error.
2N/A} {1 {database is locked}}
2N/Ado_test attach2-2.2 {
2N/Ado_test attach2-2.3 {
2N/A # unlock
test2.db and try to attach again. should work this time.
2N/Ado_test attach2-2.4 {
2N/A} {0 main 1 temp 2 t2}
2N/Ado_test attach2-2.5 {
2N/Ado_test attach2-2.6 {
2N/A # lock
test2.db and try to read from it. should get an error.
2N/A} {1 {database is locked}}
2N/Ado_test attach2-2.7 {
2N/Ado_test attach2-2.8 {
2N/A INSERT INTO t1 VALUES(8,9);
2N/Ado_test attach2-2.9 {
2N/Ado_test attach2-2.10 {
2N/A} {1 {database is locked}}
2N/Ado_test attach2-2.11 {
2N/A # when the write failed in the previous test, the transaction should
2N/Ado_test attach2-2.12 {
2N/A} {1 {cannot commit - no transaction is active}}
2N/A# Ticket #574: Make sure it works usingi the non-callback API
2N/Ado_test attach2-3.1 {
2N/A set rc [catch {sqlite_compile $DB "ATTACH '
test2.db' AS t2" TAIL} VM]
2N/A if {$rc} {lappend rc $VM}
2N/Ado_test attach2-3.2 {
2N/A set rc [catch {sqlite_compile $DB "DETACH t2" TAIL} VM]
2N/A if {$rc} {lappend rc $VM}
2N/Afor {set i 2} {$i<=15} {incr i} {