1# 2014-12-05 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# Open two database connections on the same database in shared cache 13# mode. Hold one open while repeatedly closing, reopening, and using 14# the second. 15# 16# This test is designed to demostrate that the fix for ticket 17# [e4a18565a36884b00edf66541f38c693827968ab] works. 18# 19 20 21set testdir [file dirname $argv0] 22source $testdir/tester.tcl 23if {[run_thread_tests]==0} { finish_test ; return } 24db close 25set ::testprefix sharedB 26 27set ::enable_shared_cache [sqlite3_enable_shared_cache 1] 28 29#------------------------------------------------------------------------- 30# 31do_test 1.1 { 32 sqlite3 db1 test.db 33 sqlite3 db2 test.db 34 35 db1 eval { 36 CREATE TABLE t1(x,y TEXT COLLATE nocase); 37 WITH RECURSIVE 38 c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<100) 39 INSERT INTO t1(x,y) SELECT i, printf('x%03dy',i) FROM c; 40 CREATE INDEX t1yx ON t1(y,x); 41 } 42 db2 eval { 43 SELECT x FROM t1 WHERE y='X014Y'; 44 } 45} {14} 46 47for {set j 1} {$j<=100} {incr j} { 48 do_test 1.2.$j { 49 db2 close 50 sqlite3 db2 test.db 51 db2 eval { 52 SELECT x FROM t1 WHERE y='X014Y'; 53 } 54 } {14} 55} 56 57db1 close 58db2 close 59sqlite3_enable_shared_cache $::enable_shared_cache 60finish_test 61