sl@0: # 2005 January 19 sl@0: # sl@0: # The author disclaims copyright to this source code. In place of sl@0: # a legal notice, here is a blessing: sl@0: # sl@0: # May you do good and not evil. sl@0: # May you find forgiveness for yourself and forgive others. sl@0: # May you share freely, never taking more than you give. sl@0: # sl@0: #*********************************************************************** sl@0: # sl@0: # $Id: shared3.test,v 1.4 2008/08/20 14:49:25 danielk1977 Exp $ sl@0: sl@0: set testdir [file dirname $argv0] sl@0: source $testdir/tester.tcl sl@0: db close sl@0: sl@0: ifcapable !shared_cache { sl@0: finish_test sl@0: return sl@0: } sl@0: set ::enable_shared_cache [sqlite3_enable_shared_cache 1] sl@0: sl@0: # Ticket #1824 sl@0: # sl@0: do_test shared3-1.1 { sl@0: file delete -force test.db test.db-journal sl@0: sqlite3 db1 test.db sl@0: db1 eval { sl@0: PRAGMA encoding=UTF16; sl@0: CREATE TABLE t1(x,y); sl@0: INSERT INTO t1 VALUES('abc','This is a test string'); sl@0: } sl@0: db1 close sl@0: sqlite3 db1 test.db sl@0: db1 eval {SELECT * FROM t1} sl@0: } {abc {This is a test string}} sl@0: do_test shared3-1.2 { sl@0: sqlite3 db2 test.db sl@0: db2 eval {SELECT y FROM t1 WHERE x='abc'} sl@0: } {{This is a test string}} sl@0: sl@0: db1 close sl@0: db2 close sl@0: sl@0: do_test shared3-2.1 { sl@0: sqlite3 db1 test.db sl@0: execsql { sl@0: PRAGMA main.cache_size = 10; sl@0: } db1 sl@0: } {} sl@0: do_test shared3-2.2 { sl@0: execsql { PRAGMA main.cache_size } db1 sl@0: } {10} sl@0: do_test shared3-2.3 { sl@0: sqlite3 db2 test.db sl@0: execsql { PRAGMA main.cache_size } db1 sl@0: } {10} sl@0: do_test shared3-2.4 { sl@0: execsql { PRAGMA main.cache_size } db2 sl@0: } {10} sl@0: do_test shared3-2.5 { sl@0: execsql { PRAGMA main.cache_size } db1 sl@0: } {10} sl@0: sl@0: # The cache-size should now be 10 pages. However at one point there was sl@0: # a bug that caused the cache size to return to the default value when sl@0: # a second connection was opened on the shared-cache (as happened in sl@0: # test case shared3-2.3 above). The goal of the following tests is to sl@0: # ensure that the cache-size really is 10 pages. sl@0: # sl@0: if {$::tcl_platform(platform)=="unix"} { sl@0: set alternative_name ./test.db sl@0: } else { sl@0: set alternative_name TEST.DB sl@0: } sl@0: do_test shared3-2.6 { sl@0: sqlite3 db3 $alternative_name sl@0: catchsql {select count(*) from sqlite_master} db3 sl@0: } {0 1} sl@0: do_test shared3-2.7 { sl@0: execsql { sl@0: BEGIN; sl@0: INSERT INTO t1 VALUES(10, randomblob(5000)) sl@0: } db1 sl@0: catchsql {select count(*) from sqlite_master} db3 sl@0: } {0 1} sl@0: do_test shared3-2.8 { sl@0: db3 close sl@0: execsql { sl@0: INSERT INTO t1 VALUES(10, randomblob(10000)) sl@0: } db1 sl@0: sqlite3 db3 $alternative_name sl@0: sl@0: # If the pager-cache is really still limited to 10 pages, then the INSERT sl@0: # statement above should have caused the pager to grab an exclusive lock sl@0: # on the database file so that the cache could be spilled. sl@0: # sl@0: catchsql {select count(*) from sqlite_master} db3 sl@0: } {1 {database is locked}} sl@0: sl@0: db1 close sl@0: db2 close sl@0: db3 close sl@0: sl@0: sqlite3_enable_shared_cache $::enable_shared_cache sl@0: finish_test