1# 2012 October 5 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# 12# The tests in this file are intended to show if two connections attach 13# to the same shared cache using different database names, views and 14# virtual tables may still be accessed. 15# 16 17set testdir [file dirname $argv0] 18source $testdir/tester.tcl 19set testprefix shared9 20db close 21set enable_shared_cache [sqlite3_enable_shared_cache 1] 22 23# Test organization: 24# 25# 1.* - Views. 26# 2.* - Virtual tables. 27# 28 29sqlite3 db1 test.db 30sqlite3 db2 test.db 31forcedelete test.db2 32 33do_test 1.1 { 34 db1 eval { 35 ATTACH 'test.db2' AS 'fred'; 36 CREATE TABLE fred.t1(a, b, c); 37 CREATE VIEW fred.v1 AS SELECT * FROM t1; 38 39 CREATE TABLE fred.t2(a, b); 40 CREATE TABLE fred.t3(a, b); 41 CREATE TRIGGER fred.trig AFTER INSERT ON t2 BEGIN 42 DELETE FROM t3; 43 INSERT INTO t3 SELECT * FROM t2; 44 END; 45 INSERT INTO t2 VALUES(1, 2); 46 SELECT * FROM t3; 47 } 48} {1 2} 49 50do_test 1.2 { db2 eval "ATTACH 'test.db2' AS 'jones'" } {} 51do_test 1.2 { db2 eval "SELECT * FROM v1" } {} 52do_test 1.3 { db2 eval "INSERT INTO t2 VALUES(3, 4)" } {} 53 54do_test 2.1 { 55 db1 eval { 56 CREATE VIRTUAL TABLE fred.t4 USING fts4; 57 INSERT INTO t4 VALUES('hello world'); 58 } 59} {} 60 61do_test 2.2 { 62 db2 eval { 63 INSERT INTO t4 VALUES('shared cache'); 64 SELECT * FROM t4 WHERE t4 MATCH 'hello'; 65 } 66} {{hello world}} 67 68do_test 2.3 { 69 db1 eval { 70 SELECT * FROM t4 WHERE t4 MATCH 'c*'; 71 } 72} {{shared cache}} 73 74db1 close 75db2 close 76sqlite3_enable_shared_cache $::enable_shared_cache 77finish_test 78 79