1# 2010 December 1 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. 14# 15 16set testdir [file dirname $argv0] 17source $testdir/tester.tcl 18source $testdir/lock_common.tcl 19source $testdir/wal_common.tcl 20source $testdir/malloc_common.tcl 21ifcapable !wal {finish_test ; return } 22 23#------------------------------------------------------------------------- 24# Changing to WAL mode in one connection forces the change in others. 25# 26db close 27forcedelete test.db 28 29set all_journal_modes {delete persist truncate memory off} 30foreach jmode $all_journal_modes { 31 32 do_test wal6-1.0.$jmode { 33 sqlite3 db test.db 34 execsql "PRAGMA journal_mode = $jmode;" 35 } $jmode 36 37 do_test wal6-1.1.$jmode { 38 execsql { 39 CREATE TABLE t1(a INTEGER PRIMARY KEY, b); 40 INSERT INTO t1 VALUES(1,2); 41 SELECT * FROM t1; 42 } 43 } {1 2} 44 45# Under Windows, you'll get an error trying to delete 46# a file this is already opened. For now, make sure 47# we get that error, then close the first connection 48# so the other tests work. 49if {$tcl_platform(platform)=="windows"} { 50 if {$jmode=="persist" || $jmode=="truncate"} { 51 do_test wal6-1.2.$jmode.win { 52 sqlite3 db2 test.db 53 catchsql { 54 PRAGMA journal_mode=WAL; 55 } db2 56 } {1 {disk I/O error}} 57 db2 close 58 db close 59 } 60} 61 62 do_test wal6-1.2.$jmode { 63 sqlite3 db2 test.db 64 execsql { 65 PRAGMA journal_mode=WAL; 66 INSERT INTO t1 VALUES(3,4); 67 SELECT * FROM t1 ORDER BY a; 68 } db2 69 } {wal 1 2 3 4} 70 71if {$tcl_platform(platform)=="windows"} { 72 if {$jmode=="persist" || $jmode=="truncate"} { 73 sqlite3 db test.db 74 } 75} 76 77 do_test wal6-1.3.$jmode { 78 execsql { 79 SELECT * FROM t1 ORDER BY a; 80 } 81 } {1 2 3 4} 82 83 db close 84 db2 close 85 forcedelete test.db 86 87} 88 89finish_test 90 91