blob: 2a7e49cd91c47dab71f5e94bfc99eee065c55e42 [file] [log] [blame]
drh351064b2014-12-05 14:34:30 +00001# 2014-12-05
drha895a4d2014-12-05 14:07:53 +00002#
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#
drh351064b2014-12-05 14:34:30 +000016# This test is designed to demostrate that the fix for ticket
17# [e4a18565a36884b00edf66541f38c693827968ab] works.
18#
drha895a4d2014-12-05 14:07:53 +000019
20
21set testdir [file dirname $argv0]
22source $testdir/tester.tcl
23if {[run_thread_tests]==0} { finish_test ; return }
24db close
25set ::testprefix sharedB
26
drh9c5e1e42022-08-15 12:26:26 +000027ifcapable !shared_cache {
28 finish_test
29 return
30}
31
drha895a4d2014-12-05 14:07:53 +000032set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
33
34#-------------------------------------------------------------------------
35#
36do_test 1.1 {
37 sqlite3 db1 test.db
38 sqlite3 db2 test.db
39
40 db1 eval {
41 CREATE TABLE t1(x,y TEXT COLLATE nocase);
42 WITH RECURSIVE
43 c(i) AS (VALUES(1) UNION ALL SELECT i+1 FROM c WHERE i<100)
44 INSERT INTO t1(x,y) SELECT i, printf('x%03dy',i) FROM c;
45 CREATE INDEX t1yx ON t1(y,x);
46 }
47 db2 eval {
48 SELECT x FROM t1 WHERE y='X014Y';
49 }
50} {14}
51
52for {set j 1} {$j<=100} {incr j} {
53 do_test 1.2.$j {
54 db2 close
55 sqlite3 db2 test.db
56 db2 eval {
57 SELECT x FROM t1 WHERE y='X014Y';
58 }
59 } {14}
60}
61
62db1 close
63db2 close
64sqlite3_enable_shared_cache $::enable_shared_cache
65finish_test