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
16 set testprefix shared3
19 ifcapable !shared_cache {
23 set ::enable_shared_cache [sqlite3_enable_shared_cache 1]
28 forcedelete test.db test.db-journal
31 PRAGMA encoding=UTF16;
33 INSERT INTO t1 VALUES('abc','This is a test string');
37 db1 eval {SELECT * FROM t1}
38 } {abc {This is a test string}}
41 db2 eval {SELECT y FROM t1 WHERE x='abc'}
42 } {{This is a test string}}
50 PRAGMA main.cache_size = 10;
54 execsql { PRAGMA main.cache_size } db1
58 execsql { PRAGMA main.cache_size } db1
61 execsql { PRAGMA main.cache_size } db2
64 execsql { PRAGMA main.cache_size } db1
67 # The cache-size should now be 10 pages. However at one point there was
68 # a bug that caused the cache size to return to the default value when
69 # a second connection was opened on the shared-cache (as happened in
70 # test case shared3-2.3 above). The goal of the following tests is to
71 # ensure that the cache-size really is 10 pages.
73 #if {$::tcl_platform(platform)=="unix"} {
74 # set alternative_name ./test.db
76 # set alternative_name TEST.DB
79 #sqlite3 db3 $alternative_name
80 sqlite3 db3 "file:./test.db?cache=private" -uri 1
81 catchsql {select count(*) from sqlite_master} db3
86 INSERT INTO t1 VALUES(10, randomblob(5000))
88 catchsql {select count(*) from sqlite_master} db3
93 INSERT INTO t1 VALUES(10, randomblob(10000))
96 # If the pager-cache is really still limited to 10 pages, then the INSERT
97 # statement above should have caused the pager to grab an exclusive lock
98 # on the database file so that the cache could be spilled.
100 catch { sqlite3 db3 "file:./test.db?cache=private" -uri 1 }
101 catchsql {select count(*) from sqlite_master} db3
102 } {1 {database is locked}}
108 #-------------------------------------------------------------------------
109 # At one point this was causing a faulty assert to fail.
114 do_execsql_test 3.1 {
115 PRAGMA auto_vacuum = 2;
116 CREATE TABLE t1(x, y);
117 INSERT INTO t1 VALUES(randomblob(500), randomblob(500));
118 INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1;
119 INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1;
120 INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1;
121 INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1;
122 INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1;
123 INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1;
124 INSERT INTO t1 SELECT randomblob(500), randomblob(500) FROM t1;
127 execsql { SELECT count(*) FROM sqlite_master } db2
129 do_execsql_test 3.3 {
131 DELETE FROM t1 WHERE 1;
132 PRAGMA incremental_vacuum;
135 execsql { SELECT count(*) FROM sqlite_master } db2
141 sqlite3_enable_shared_cache $::enable_shared_cache