2d4583473b
FossilOrigin-Name: 7a0f8024a1323a15d0c83afe9302400736f01fe8
73 lines
1.5 KiB
Plaintext
73 lines
1.5 KiB
Plaintext
# 2003 April 4
|
|
#
|
|
# 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 testing the ATTACH and DETACH commands
|
|
# and related functionality.
|
|
#
|
|
# $Id: attach.test,v 1.1 2003/04/05 03:42:27 drh Exp $
|
|
#
|
|
|
|
set testdir [file dirname $argv0]
|
|
source $testdir/tester.tcl
|
|
|
|
file delete -force test2.db
|
|
file delete -force test2.db-journal
|
|
|
|
do_test attach-1.1 {
|
|
execsql {
|
|
CREATE TABLE t1(a,b);
|
|
INSERT INTO t1 VALUES(1,2);
|
|
INSERT INTO t1 VALUES(3,4);
|
|
SELECT * FROM t1;
|
|
}
|
|
} {1 2 3 4}
|
|
do_test attach-1.2 {
|
|
sqlite db2 test2.db
|
|
execsql {
|
|
CREATE TABLE t2(x,y);
|
|
INSERT INTO t2 VALUES(1,'x');
|
|
INSERT INTO t2 VALUES(2,'y');
|
|
SELECT * FROM t2;
|
|
}
|
|
} {1 x 2 y}
|
|
do_test attach-1.3 {
|
|
execsql {
|
|
ATTACH DATABASE 'test2.db' AS two;
|
|
SELECT * FROM two.t2;
|
|
}
|
|
} {1 x 2 y}
|
|
do_test attach-1.4 {
|
|
execsql {
|
|
SELECT * FROM t2;
|
|
}
|
|
} {1 x 2 y}
|
|
do_test attach-1.5 {
|
|
execsql {
|
|
DETACH DATABASE two;
|
|
SELECT * FROM t1;
|
|
}
|
|
} {1 2 3 4}
|
|
do_test attach-1.6 {
|
|
catchsql {
|
|
SELECT * FROM t2;
|
|
}
|
|
} {1 {no such table: t2}}
|
|
do_test attach-1.7 {
|
|
catchsql {
|
|
SELECT * FROM two.t2;
|
|
}
|
|
} {1 {no such table: two.t2}}
|
|
|
|
db2 close
|
|
|
|
|
|
finish_test
|