1f602963dSdan# 2012 February 28 2f602963dSdan# 3f602963dSdan# The author disclaims copyright to this source code. In place of 4f602963dSdan# a legal notice, here is a blessing: 5f602963dSdan# 6f602963dSdan# May you do good and not evil. 7f602963dSdan# May you find forgiveness for yourself and forgive others. 8f602963dSdan# May you share freely, never taking more than you give. 9f602963dSdan# 10f602963dSdan#*********************************************************************** 11f602963dSdan# This file implements regression tests for SQLite library. The 12f602963dSdan# focus of this file is testing the operation of the library in 13f602963dSdan# "PRAGMA journal_mode=WAL" mode. 14f602963dSdan# 15f602963dSdan# Specifically, it tests the case where a connection opens an empty 16f602963dSdan# file. Then, another connection opens the same file and initializes 17f602963dSdan# the connection as a WAL database. Following this, the first connection 18f602963dSdan# executes a "PRAGMA page_size = XXX" command to set its expected page 19f602963dSdan# size, and then queries the database. 20f602963dSdan# 21f602963dSdan# This is an unusual case, as normally SQLite is able to glean the page 22f602963dSdan# size from the database file as soon as it is opened (even before the 23f602963dSdan# first read transaction is executed), and the "PRAGMA page_size = XXX" 24f602963dSdan# is a no-op. 25f602963dSdan# 26f602963dSdanset testdir [file dirname $argv0] 27f602963dSdansource $testdir/tester.tcl 28f602963dSdanset ::testprefix wal8 29c60941f8Smistachkinifcapable !wal {finish_test ; return } 30*7da56b4fSdrhdo_not_use_codec 31f602963dSdan 32f602963dSdandb close 33f602963dSdanforcedelete test.db test.db-wal 34f602963dSdan 35f602963dSdansqlite3 db test.db 36f602963dSdansqlite3 db2 test.db 37f602963dSdan 38f602963dSdando_test 1.0 { 39f602963dSdan execsql { 40f602963dSdan PRAGMA journal_mode = wal; 41f602963dSdan CREATE TABLE t1(a, b); 42f602963dSdan INSERT INTO t1 VALUES(1, 2); 43f602963dSdan } db2 44f602963dSdan} {wal} 45f602963dSdan 46f602963dSdando_catchsql_test 1.1 { 47f602963dSdan PRAGMA page_size = 4096; 48f602963dSdan VACUUM; 49f602963dSdan} {0 {}} 50f602963dSdan 51f602963dSdandb close 52f602963dSdandb2 close 53f602963dSdanforcedelete test.db test.db-wal 54f602963dSdan 55f602963dSdansqlite3 db test.db 56f602963dSdansqlite3 db2 test.db 57f602963dSdan 58f602963dSdando_test 2.0 { 59f602963dSdan execsql { 60f602963dSdan CREATE TABLE t1(a, b); 61f602963dSdan INSERT INTO t1 VALUES(1, 2); 62f602963dSdan PRAGMA journal_mode = wal; 63f602963dSdan } db2 64f602963dSdan} {wal} 65f602963dSdan 66f602963dSdando_catchsql_test 2.1 { 67f602963dSdan PRAGMA page_size = 4096; 68f602963dSdan VACUUM; 69f602963dSdan} {0 {}} 70f602963dSdan 71f602963dSdandb close 72f602963dSdandb2 close 73f602963dSdanforcedelete test.db test.db-wal 74f602963dSdan 75f602963dSdansqlite3 db test.db 76f602963dSdansqlite3 db2 test.db 77f602963dSdan 78f602963dSdando_test 3.0 { 79f602963dSdan execsql { 80f602963dSdan PRAGMA journal_mode = wal; 81f602963dSdan CREATE TABLE t1(a, b); 82f602963dSdan INSERT INTO t1 VALUES(1, 2); 83f602963dSdan } db2 84f602963dSdan} {wal} 85f602963dSdan 86f602963dSdando_execsql_test 3.1 { 87f602963dSdan PRAGMA page_size = 4096; 88f602963dSdan SELECT name FROM sqlite_master; 89f602963dSdan} {t1} 90f602963dSdan 91f602963dSdanfinish_test 92