1351064b4Sdrh# 2014-12-05 2a895a4d2Sdrh# 3a895a4d2Sdrh# The author disclaims copyright to this source code. In place of 4a895a4d2Sdrh# a legal notice, here is a blessing: 5a895a4d2Sdrh# 6a895a4d2Sdrh# May you do good and not evil. 7a895a4d2Sdrh# May you find forgiveness for yourself and forgive others. 8a895a4d2Sdrh# May you share freely, never taking more than you give. 9a895a4d2Sdrh# 10a895a4d2Sdrh#*********************************************************************** 11a895a4d2Sdrh# 12a895a4d2Sdrh# Open two database connections on the same database in shared cache 13a895a4d2Sdrh# mode. Hold one open while repeatedly closing, reopening, and using 14a895a4d2Sdrh# the second. 15a895a4d2Sdrh# 16351064b4Sdrh# This test is designed to demostrate that the fix for ticket 17351064b4Sdrh# [e4a18565a36884b00edf66541f38c693827968ab] works. 18351064b4Sdrh# 19a895a4d2Sdrh 20a895a4d2Sdrh 21a895a4d2Sdrhset testdir [file dirname $argv0] 22a895a4d2Sdrhsource $testdir/tester.tcl 23a895a4d2Sdrhif {[run_thread_tests]==0} { finish_test ; return } 24a895a4d2Sdrhdb close 25a895a4d2Sdrhset ::testprefix sharedB 26a895a4d2Sdrh 27*9c5e1e40Sdrhifcapable !shared_cache { 28*9c5e1e40Sdrh finish_test 29*9c5e1e40Sdrh return 30*9c5e1e40Sdrh} 31*9c5e1e40Sdrh 32a895a4d2Sdrhset ::enable_shared_cache [sqlite3_enable_shared_cache 1] 33a895a4d2Sdrh 34a895a4d2Sdrh#------------------------------------------------------------------------- 35a895a4d2Sdrh# 36a895a4d2Sdrhdo_test 1.1 { 37a895a4d2Sdrh sqlite3 db1 test.db 38a895a4d2Sdrh sqlite3 db2 test.db 39a895a4d2Sdrh 40a895a4d2Sdrh db1 eval { 41a895a4d2Sdrh CREATE TABLE t1(x,y TEXT COLLATE nocase); 42a895a4d2Sdrh WITH RECURSIVE 43a895a4d2Sdrh c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<100) 44a895a4d2Sdrh INSERT INTO t1(x,y) SELECT i, printf('x%03dy',i) FROM c; 45a895a4d2Sdrh CREATE INDEX t1yx ON t1(y,x); 46a895a4d2Sdrh } 47a895a4d2Sdrh db2 eval { 48a895a4d2Sdrh SELECT x FROM t1 WHERE y='X014Y'; 49a895a4d2Sdrh } 50a895a4d2Sdrh} {14} 51a895a4d2Sdrh 52a895a4d2Sdrhfor {set j 1} {$j<=100} {incr j} { 53a895a4d2Sdrh do_test 1.2.$j { 54a895a4d2Sdrh db2 close 55a895a4d2Sdrh sqlite3 db2 test.db 56a895a4d2Sdrh db2 eval { 57a895a4d2Sdrh SELECT x FROM t1 WHERE y='X014Y'; 58a895a4d2Sdrh } 59a895a4d2Sdrh } {14} 60a895a4d2Sdrh} 61a895a4d2Sdrh 62a895a4d2Sdrhdb1 close 63a895a4d2Sdrhdb2 close 64a895a4d2Sdrhsqlite3_enable_shared_cache $::enable_shared_cache 65a895a4d2Sdrhfinish_test 66