1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-07-29 08:01:23 +03:00

Tighter binding of views, triggers, and indices to their respective

databases.  Ticket #323.  Much more testing needs to be done to the
sqliteFix...() routines in attach.c. (CVS 990)

FossilOrigin-Name: 7202d4f1a8853368954a967b7ccca9d8a6645a2e
This commit is contained in:
drh
2003-05-31 16:21:12 +00:00
parent 8372b8d134
commit f26e09c87f
13 changed files with 373 additions and 72 deletions

View File

@ -12,7 +12,7 @@
# focus of this script is testing the ATTACH and DETACH commands
# and related functionality.
#
# $Id: attach.test,v 1.5 2003/05/17 19:23:52 drh Exp $
# $Id: attach.test,v 1.6 2003/05/31 16:21:13 drh Exp $
#
set testdir [file dirname $argv0]
@ -369,6 +369,107 @@ do_test attach-3.14 {
execsql {SELECT * FROM t1}
} {1 2 3 4}
# Ticket #323
do_test attach-4.1 {
execsql {DETACH db2}
db2 close
sqlite db2 test2.db
execsql {
CREATE TABLE t3(x,y);
CREATE UNIQUE INDEX t3i1 ON t3(x);
INSERT INTO t3 VALUES(1,2);
SELECT * FROM t3;
} db2;
} {1 2}
do_test attach-4.2 {
execsql {
CREATE TABLE t3(a,b);
CREATE UNIQUE INDEX t3i1b ON t3(a);
INSERT INTO t3 VALUES(9,10);
SELECT * FROM t3;
}
} {9 10}
do_test attach-4.3 {
execsql {
ATTACH DATABASE 'test2.db' AS db2;
SELECT * FROM db2.t3;
}
} {1 2}
do_test attach-4.4 {
execsql {
SELECT * FROM main.t3;
}
} {9 10}
do_test attach-4.5 {
execsql {
INSERT INTO db2.t3 VALUES(9,10);
SELECT * FROM db2.t3;
}
} {1 2 9 10}
do_test attach-4.6 {
execsql {
DETACH db2;
}
execsql {
CREATE TABLE t4(x);
CREATE TRIGGER t3r3 AFTER INSERT ON t3 BEGIN
INSERT INTO t4 VALUES('db2.' || NEW.x);
END;
INSERT INTO t3 VALUES(6,7);
SELECT * FROM t4;
} db2
} {db2.6}
do_test attach-4.7 {
execsql {
CREATE TABLE t4(y);
CREATE TRIGGER t3r3 AFTER INSERT ON t3 BEGIN
INSERT INTO t4 VALUES('main.' || NEW.a);
END;
INSERT INTO main.t3 VALUES(11,12);
SELECT * FROM main.t4;
}
} {main.11}
do_test attach-4.8 {
execsql {
ATTACH DATABASE 'test2.db' AS db2;
INSERT INTO db2.t3 VALUES(13,14);
SELECT * FROM db2.t4 UNION ALL SELECT * FROM main.t4;
}
} {db2.6 db2.13 main.11}
do_test attach-4.9 {
execsql {
INSERT INTO main.t3 VALUES(15,16);
SELECT * FROM db2.t4 UNION ALL SELECT * FROM main.t4;
}
} {db2.6 db2.13 main.11 main.15}
do_test attach-4.10 {
execsql {
DETACH DATABASE db2;
}
execsql {
CREATE VIEW v3 AS SELECT x*100+y FROM t3;
SELECT * FROM v3;
} db2
} {102 910 607 1314}
do_test attach-4.11 {
execsql {
CREATE VIEW v3 AS SELECT a*100+b FROM t3;
SELECT * FROM v3;
}
} {910 1112 1516}
do_test attach-4.12 {
execsql {
ATTACH DATABASE 'test2.db' AS db2;
SELECT * FROM db2.v3;
}
} {102 910 607 1314}
do_test attach-4.13 {
execsql {
SELECT * FROM main.v3;
}
} {910 1112 1516}
for {set i 2} {$i<=15} {incr i} {
catch {db$i close}
}

View File

@ -222,7 +222,7 @@ do_test trigger-3.2 {
INSERT INTO t1 VALUES(1,2);
SELECT * FROM t2;
}
} {1 {table "t2" is not in database "main"}}
} {1 {no such table: main.t2}}
do_test trigger-3.3 {
db close
set rc [catch {sqlite db test.db} err]
@ -234,14 +234,14 @@ do_test trigger-3.4 {
INSERT INTO t1 VALUES(1,2);
SELECT * FROM t2;
}
} {1 {no such table: t2}}
} {1 {no such table: main.t2}}
do_test trigger-3.5 {
catchsql {
CREATE TEMP TABLE t2(x,y);
INSERT INTO t1 VALUES(1,2);
SELECT * FROM t2;
}
} {1 {table "t2" is not in database "main"}}
} {1 {no such table: main.t2}}
do_test trigger-3.6 {
catchsql {
DROP TRIGGER r1;

View File

@ -83,19 +83,19 @@ do_test trigger4-3.1 {
drop table test2;
insert into test values(7,8,9);
}
} {1 {no such table: test2}}
} {1 {no such table: main.test2}}
do_test trigger4-3.2 {
db close
sqlite db test.db
catchsql {
insert into test values(7,8,9);
}
} {1 {no such table: test2}}
} {1 {no such table: main.test2}}
do_test trigger4-3.3 {
catchsql {
update test set a=222 where id=1;
}
} {1 {no such table: test2}}
} {1 {no such table: main.test2}}
do_test trigger4-3.4 {
execsql {
select * from test1;

View File

@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is testing VIEW statements.
#
# $Id: view.test,v 1.15 2003/05/02 16:04:17 drh Exp $
# $Id: view.test,v 1.16 2003/05/31 16:21:13 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -68,7 +68,7 @@ do_test view-1.6 {
DROP TABLE t1;
SELECT * FROM v1 ORDER BY a;
}
} {1 {no such table: t1}}
} {1 {no such table: main.t1}}
do_test view-1.7 {
execsql {
CREATE TABLE t1(x,a,b,c);