Add the SQLITE_DBCONFIG_RESET_DATABASE control for resetting a corrupt
[sqlite.git] / test / wal8.test
blob3e5a0c2617599a093181b231f88ade992a7a7f7f
1 # 2012 February 28
3 # The author disclaims copyright to this source code.  In place of
4 # a legal notice, here is a blessing:
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.
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.
15 # Specifically, it tests the case where a connection opens an empty
16 # file. Then, another connection opens the same file and initializes
17 # the connection as a WAL database. Following this, the first connection
18 # executes a "PRAGMA page_size = XXX" command to set its expected page
19 # size, and then queries the database.
21 # This is an unusual case, as normally SQLite is able to glean the page
22 # size from the database file as soon as it is opened (even before the
23 # first read transaction is executed), and the "PRAGMA page_size = XXX"
24 # is a no-op.
26 set testdir [file dirname $argv0]
27 source $testdir/tester.tcl
28 set ::testprefix wal8
29 ifcapable !wal {finish_test ; return }
30 do_not_use_codec
32 db close
33 forcedelete test.db test.db-wal
35 sqlite3 db test.db
36 sqlite3 db2 test.db
38 do_test 1.0 {
39   execsql {
40     PRAGMA journal_mode = wal;
41     CREATE TABLE t1(a, b);
42     INSERT INTO t1 VALUES(1, 2);
43   } db2
44 } {wal}
46 do_catchsql_test 1.1 {
47   PRAGMA page_size = 4096;
48   VACUUM;
49 } {0 {}}
51 db close
52 db2 close
53 forcedelete test.db test.db-wal
55 sqlite3 db test.db
56 sqlite3 db2 test.db
58 do_test 2.0 {
59   execsql {
60     CREATE TABLE t1(a, b);
61     INSERT INTO t1 VALUES(1, 2);
62     PRAGMA journal_mode = wal;
63   } db2
64 } {wal}
66 do_catchsql_test 2.1 {
67   PRAGMA page_size = 4096;
68   VACUUM;
69 } {0 {}}
71 db close
72 db2 close
73 forcedelete test.db test.db-wal
75 sqlite3 db test.db
76 sqlite3 db2 test.db
78 do_test 3.0 {
79   execsql {
80     PRAGMA journal_mode = wal;
81     CREATE TABLE t1(a, b);
82     INSERT INTO t1 VALUES(1, 2);
83   } db2
84 } {wal}
86 do_execsql_test 3.1 {
87   PRAGMA page_size = 4096;
88   SELECT name FROM sqlite_master;
89 } {t1}
91 finish_test