176ed3bc0Sdan# 2010 May 03 276ed3bc0Sdan# 376ed3bc0Sdan# The author disclaims copyright to this source code. In place of 476ed3bc0Sdan# a legal notice, here is a blessing: 576ed3bc0Sdan# 676ed3bc0Sdan# May you do good and not evil. 776ed3bc0Sdan# May you find forgiveness for yourself and forgive others. 876ed3bc0Sdan# May you share freely, never taking more than you give. 976ed3bc0Sdan# 1076ed3bc0Sdan#*********************************************************************** 1176ed3bc0Sdan# This file implements regression tests for SQLite library. The 1276ed3bc0Sdan# focus of this file is testing the operation of the library in 1376ed3bc0Sdan# "PRAGMA journal_mode=WAL" mode. 1476ed3bc0Sdan# 1576ed3bc0Sdan 1676ed3bc0Sdanset testdir [file dirname $argv0] 1776ed3bc0Sdansource $testdir/tester.tcl 1876ed3bc0Sdansource $testdir/malloc_common.tcl 1976ed3bc0Sdan 2076ed3bc0Sdanifcapable !wal {finish_test ; return } 2176ed3bc0Sdan 2276ed3bc0Sdando_malloc_test walfault-oom-1 -sqlbody { 2376ed3bc0Sdan PRAGMA journal_mode = WAL; 2476ed3bc0Sdan CREATE TABLE t1(a, b); 2576ed3bc0Sdan INSERT INTO t1 VALUES(1, 2); 2676ed3bc0Sdan PRAGMA checkpoint; 2776ed3bc0Sdan} 2876ed3bc0Sdan 29*5e9e482fSdando_malloc_test walfault-oom-2 -tclprep { 30*5e9e482fSdan execsql { 31*5e9e482fSdan PRAGMA journal_mode = WAL; 32*5e9e482fSdan BEGIN; 33*5e9e482fSdan CREATE TABLE x(y, z, UNIQUE(y, z)); 34*5e9e482fSdan INSERT INTO x VALUES(randomblob(100), randomblob(100)); 35*5e9e482fSdan COMMIT; 36*5e9e482fSdan PRAGMA wal_checkpoint; 37*5e9e482fSdan 38*5e9e482fSdan INSERT INTO x SELECT randomblob(100), randomblob(100) FROM x; 39*5e9e482fSdan INSERT INTO x SELECT randomblob(100), randomblob(100) FROM x; 40*5e9e482fSdan INSERT INTO x SELECT randomblob(100), randomblob(100) FROM x; 41*5e9e482fSdan } 42*5e9e482fSdan file copy -force test.db testX.db 43*5e9e482fSdan file copy -force test.db-wal testX.db-wal 44*5e9e482fSdan db close 45*5e9e482fSdan file rename -force testX.db test.db 46*5e9e482fSdan file rename -force testX.db-wal test.db-wal 47*5e9e482fSdan 48*5e9e482fSdan sqlite3 db test.db 49*5e9e482fSdan sqlite3_extended_result_codes db 1 50*5e9e482fSdan sqlite3_db_config_lookaside db 0 0 0 51*5e9e482fSdan} -sqlbody { 52*5e9e482fSdan SELECT count(*) FROM x; 53*5e9e482fSdan} 54*5e9e482fSdan 5576ed3bc0Sdan 5676ed3bc0Sdanfinish_test 57