1# 2010 August 2 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# This file implements regression tests for SQLite library. The 12# focus of this file is testing the operation of the library in 13# "PRAGMA journal_mode=WAL" mode with shared-cache turned on. 14# 15 16set testdir [file dirname $argv0] 17source $testdir/tester.tcl 18 19ifcapable !wal {finish_test ; return } 20 21db close 22set ::enable_shared_cache [sqlite3_enable_shared_cache 1] 23 24sqlite3 db test.db 25sqlite3 db2 test.db 26 27do_test walshared-1.0 { 28 execsql { 29 PRAGMA cache_size = 10; 30 PRAGMA journal_mode = WAL; 31 CREATE TABLE t1(a PRIMARY KEY, b UNIQUE); 32 INSERT INTO t1 VALUES(randomblob(100), randomblob(200)); 33 } 34} {wal} 35 36do_test walshared-1.1 { 37 execsql { 38 BEGIN; 39 INSERT INTO t1 VALUES(randomblob(100), randomblob(200)); 40 INSERT INTO t1 SELECT randomblob(100), randomblob(200) FROM t1; 41 INSERT INTO t1 SELECT randomblob(100), randomblob(200) FROM t1; 42 INSERT INTO t1 SELECT randomblob(100), randomblob(200) FROM t1; 43 } 44} {} 45 46do_test walshared-1.2 { 47 catchsql { PRAGMA wal_checkpoint } 48} {1 {database table is locked}} 49 50do_test walshared-1.3 { 51 catchsql { PRAGMA wal_checkpoint } db2 52} {1 {database table is locked}} 53 54do_test walshared-1.4 { 55 execsql { COMMIT } 56 execsql { PRAGMA integrity_check } db2 57} {ok} 58 59 60 61sqlite3_enable_shared_cache $::enable_shared_cache 62finish_test 63