3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
12 # $Id: shared3.test,v 1.4 2008/08/20 14:49:25 danielk1977 Exp $
14 set testdir [file dirname $argv0]
15 source $testdir/tester.tcl
18 ifcapable !shared_cache {
22 set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
27 file delete -force test.db test.db-journal
30 PRAGMA encoding=UTF16;
32 INSERT INTO t1 VALUES('abc','This is a test string');
36 db1 eval {SELECT * FROM t1}
37 } {abc {This is a test string}}
40 db2 eval {SELECT y FROM t1 WHERE x='abc'}
41 } {{This is a test string}}
49 PRAGMA main.cache_size = 10;
53 execsql { PRAGMA main.cache_size } db1
57 execsql { PRAGMA main.cache_size } db1
60 execsql { PRAGMA main.cache_size } db2
63 execsql { PRAGMA main.cache_size } db1
66 # The cache-size should now be 10 pages. However at one point there was
67 # a bug that caused the cache size to return to the default value when
68 # a second connection was opened on the shared-cache (as happened in
69 # test case shared3-2.3 above). The goal of the following tests is to
70 # ensure that the cache-size really is 10 pages.
72 if {$::tcl_platform(platform)=="unix"} {
73 set alternative_name ./test.db
75 set alternative_name TEST.DB
78 sqlite3 db3 $alternative_name
79 catchsql {select count(*) from sqlite_master} db3
84 INSERT INTO t1 VALUES(10, randomblob(5000))
86 catchsql {select count(*) from sqlite_master} db3
91 INSERT INTO t1 VALUES(10, randomblob(10000))
94 # If the pager-cache is really still limited to 10 pages, then the INSERT
95 # statement above should have caused the pager to grab an exclusive lock
96 # on the database file so that the cache could be spilled.
98 catch { sqlite3 db3 $alternative_name }
99 catchsql {select count(*) from sqlite_master} db3
100 } {1 {database is locked}}
106 sqlite3_enable_shared_cache $::enable_shared_cache