blob: 3e5a0c2617599a093181b231f88ade992a7a7f7f [file] [log] [blame]
danf6029632012-02-28 17:57:34 +00001# 2012 February 28
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# 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.
20#
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.
25#
26set testdir [file dirname $argv0]
27source $testdir/tester.tcl
28set ::testprefix wal8
mistachkinc60941f2012-09-13 01:51:02 +000029ifcapable !wal {finish_test ; return }
drh7da56b42016-03-14 18:34:42 +000030do_not_use_codec
danf6029632012-02-28 17:57:34 +000031
32db close
33forcedelete test.db test.db-wal
34
35sqlite3 db test.db
36sqlite3 db2 test.db
37
38do_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}
45
46do_catchsql_test 1.1 {
47 PRAGMA page_size = 4096;
48 VACUUM;
49} {0 {}}
50
51db close
52db2 close
53forcedelete test.db test.db-wal
54
55sqlite3 db test.db
56sqlite3 db2 test.db
57
58do_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}
65
66do_catchsql_test 2.1 {
67 PRAGMA page_size = 4096;
68 VACUUM;
69} {0 {}}
70
71db close
72db2 close
73forcedelete test.db test.db-wal
74
75sqlite3 db test.db
76sqlite3 db2 test.db
77
78do_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}
85
86do_execsql_test 3.1 {
87 PRAGMA page_size = 4096;
88 SELECT name FROM sqlite_master;
89} {t1}
90
91finish_test