1# 2003 July 1 2# 3# The author disclaims copyright to this source code. In place of 4# a legal notice, here is a blessing: 5# 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. 9# 10#*********************************************************************** 11# This file implements regression tests for SQLite library. The 12# focus of this script is testing the ATTACH and DETACH commands 13# and schema changes to attached databases. 14# 15# $Id: attach3.test,v 1.1 2004/05/28 11:37:29 danielk1977 Exp $ 16# 17 18 19set testdir [file dirname $argv0] 20source $testdir/tester.tcl 21 22# Create tables t1 and t2 in the main database 23execsql { 24 CREATE TABLE t1(a, b); 25 CREATE TABLE t2(c, d); 26} 27 28# Create tables t1 and t2 in database file test2.db 29file delete -force test2.db 30sqlite db2 test2.db 31execsql { 32 CREATE TABLE t1(a, b); 33 CREATE TABLE t2(c, d); 34} db2 35db2 close 36 37# Create a table in the auxilary database. 38do_test attach3-1 { 39 execsql { 40 ATTACH 'test2.db' AS aux; 41 } 42} {} 43do_test attach3-2 { 44 execsql { 45 CREATE TABLE aux.t3(e, f); 46 } 47} {} 48do_test attach3-3 { 49 execsql { 50 SELECT * FROM sqlite_master WHERE name = 't3'; 51 } 52} {} 53do_test attach3-4 { 54 execsql { 55 SELECT * FROM aux.sqlite_master WHERE name = 't3'; 56 } 57} {table t3 t3 4 {CREATE TABLE t3(e, f)}} 58do_test attach3-5 { 59 execsql { 60 INSERT INTO t3 VALUES(1, 2); 61 SELECT * FROM t3; 62 } 63} {1 2} 64 65# Create an index on the auxilary database table. 66do_test attach4-1 { 67 execsql { 68 CREATE INDEX aux.i1 on t3(e); 69 } 70} {} 71execsql { 72 pragma vdbe_trace = off; 73} 74do_test attach4-2 { 75 execsql { 76 SELECT * FROM sqlite_master WHERE name = 'i1'; 77 } 78} {} 79do_test attach4-3 { 80 execsql { 81 SELECT * FROM aux.sqlite_master WHERE name = 'i1'; 82 } 83} {index i1 t3 5 {CREATE INDEX i1 on t3(e)}} 84 85finish_test 86 87 88 89 90