mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-01 06:27:03 +03:00
More testing of ATTACH and DETACH. (CVS 899)
FossilOrigin-Name: 51f515f28cb1cc3e8f0c3531724dc8876b25f18e
This commit is contained in:
147
test/attach.test
147
test/attach.test
@ -12,14 +12,16 @@
|
||||
# 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 $
|
||||
# $Id: attach.test,v 1.2 2003/04/05 16:56:30 drh Exp $
|
||||
#
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
file delete -force test2.db
|
||||
file delete -force test2.db-journal
|
||||
for {set i 2} {$i<=15} {incr i} {
|
||||
file delete -force test$i.db
|
||||
file delete -force test$i.db-journal
|
||||
}
|
||||
|
||||
do_test attach-1.1 {
|
||||
execsql {
|
||||
@ -36,7 +38,7 @@ do_test attach-1.2 {
|
||||
INSERT INTO t2 VALUES(1,'x');
|
||||
INSERT INTO t2 VALUES(2,'y');
|
||||
SELECT * FROM t2;
|
||||
}
|
||||
} db2
|
||||
} {1 x 2 y}
|
||||
do_test attach-1.3 {
|
||||
execsql {
|
||||
@ -65,8 +67,143 @@ do_test attach-1.7 {
|
||||
SELECT * FROM two.t2;
|
||||
}
|
||||
} {1 {no such table: two.t2}}
|
||||
do_test attach-1.8 {
|
||||
catchsql {
|
||||
ATTACH DATABASE 'test3.db' AS three;
|
||||
}
|
||||
} {1 {cannot attach empty database: three}}
|
||||
do_test attach-1.9 {
|
||||
catchsql {
|
||||
SELECT * FROM three.sqlite_master;
|
||||
}
|
||||
} {1 {no such table: three.sqlite_master}}
|
||||
do_test attach-1.10 {
|
||||
catchsql {
|
||||
DETACH DATABASE three;
|
||||
}
|
||||
} {1 {no such database: three}}
|
||||
do_test attach-1.11 {
|
||||
execsql {
|
||||
ATTACH 'test.db' AS db2;
|
||||
ATTACH 'test.db' AS db3;
|
||||
ATTACH 'test.db' AS db4;
|
||||
ATTACH 'test.db' AS db5;
|
||||
ATTACH 'test.db' AS db6;
|
||||
ATTACH 'test.db' AS db7;
|
||||
ATTACH 'test.db' AS db8;
|
||||
ATTACH 'test.db' AS db9;
|
||||
}
|
||||
} {}
|
||||
do_test attach-1.11b {
|
||||
execsql {
|
||||
PRAGMA database_list;
|
||||
}
|
||||
} {0 main 1 temp 2 db2 3 db3 4 db4 5 db5 6 db6 7 db7 8 db8 9 db9}
|
||||
do_test attach-1.12 {
|
||||
catchsql {
|
||||
ATTACH 'test.db' as db2;
|
||||
}
|
||||
} {1 {database db2 is already in use}}
|
||||
do_test attach-1.13 {
|
||||
catchsql {
|
||||
ATTACH 'test.db' as db5;
|
||||
}
|
||||
} {1 {database db5 is already in use}}
|
||||
do_test attach-1.14 {
|
||||
catchsql {
|
||||
ATTACH 'test.db' as db9;
|
||||
}
|
||||
} {1 {database db9 is already in use}}
|
||||
do_test attach-1.15 {
|
||||
catchsql {
|
||||
ATTACH 'test.db' as main;
|
||||
}
|
||||
} {1 {database main is already in use}}
|
||||
do_test attach-1.16 {
|
||||
catchsql {
|
||||
ATTACH 'test.db' as temp;
|
||||
}
|
||||
} {1 {database temp is already in use}}
|
||||
do_test attach-1.17 {
|
||||
catchsql {
|
||||
ATTACH 'test.db' as MAIN;
|
||||
}
|
||||
} {1 {database MAIN is already in use}}
|
||||
do_test attach-1.18 {
|
||||
catchsql {
|
||||
ATTACH 'test.db' as db10;
|
||||
ATTACH 'test.db' as db11;
|
||||
}
|
||||
} {0 {}}
|
||||
do_test attach-1.19 {
|
||||
catchsql {
|
||||
ATTACH 'test.db' as db12;
|
||||
}
|
||||
} {1 {too many attached databases - max 10}}
|
||||
do_test attach-1.20 {
|
||||
execsql {
|
||||
DETACH db5;
|
||||
PRAGMA database_list;
|
||||
}
|
||||
} {0 main 1 temp 2 db2 3 db3 4 db4 5 db11 6 db6 7 db7 8 db8 9 db9 10 db10}
|
||||
do_test attach-1.21 {
|
||||
catchsql {
|
||||
ATTACH 'test.db' as db12;
|
||||
}
|
||||
} {0 {}}
|
||||
do_test attach-1.22 {
|
||||
catchsql {
|
||||
ATTACH 'test.db' as db13;
|
||||
}
|
||||
} {1 {too many attached databases - max 10}}
|
||||
do_test attach-1.23 {
|
||||
catchsql {
|
||||
DETACH db14;
|
||||
}
|
||||
} {1 {no such database: db14}}
|
||||
do_test attach-1.24 {
|
||||
catchsql {
|
||||
DETACH db12;
|
||||
}
|
||||
} {0 {}}
|
||||
do_test attach-1.25 {
|
||||
catchsql {
|
||||
DETACH db12;
|
||||
}
|
||||
} {1 {no such database: db12}}
|
||||
do_test attach-1.26 {
|
||||
catchsql {
|
||||
DETACH main;
|
||||
}
|
||||
} {1 {cannot detach database main}}
|
||||
do_test attach-1.27 {
|
||||
catchsql {
|
||||
DETACH Temp;
|
||||
}
|
||||
} {1 {cannot detach database Temp}}
|
||||
do_test attach-1.28 {
|
||||
catchsql {
|
||||
DETACH db11;
|
||||
DETACH db10;
|
||||
DETACH db9;
|
||||
DETACH db8;
|
||||
DETACH db7;
|
||||
DETACH db6;
|
||||
DETACH db4;
|
||||
DETACH db3;
|
||||
DETACH db2;
|
||||
}
|
||||
} {0 {}}
|
||||
do_test attach-1.29 {
|
||||
execsql {
|
||||
PRAGMA database_list
|
||||
}
|
||||
} {0 main 1 temp}
|
||||
|
||||
db2 close
|
||||
|
||||
for {set i 2} {$i<=15} {incr i} {
|
||||
catch {db$i close}
|
||||
}
|
||||
|
||||
|
||||
finish_test
|
||||
|
Reference in New Issue
Block a user