OLD | NEW |
| (Empty) |
1 # 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 # | |
26 set testdir [file dirname $argv0] | |
27 source $testdir/tester.tcl | |
28 set ::testprefix wal8 | |
29 ifcapable !wal {finish_test ; return } | |
30 | |
31 db close | |
32 forcedelete test.db test.db-wal | |
33 | |
34 sqlite3 db test.db | |
35 sqlite3 db2 test.db | |
36 | |
37 do_test 1.0 { | |
38 execsql { | |
39 PRAGMA journal_mode = wal; | |
40 CREATE TABLE t1(a, b); | |
41 INSERT INTO t1 VALUES(1, 2); | |
42 } db2 | |
43 } {wal} | |
44 | |
45 do_catchsql_test 1.1 { | |
46 PRAGMA page_size = 4096; | |
47 VACUUM; | |
48 } {0 {}} | |
49 | |
50 db close | |
51 db2 close | |
52 forcedelete test.db test.db-wal | |
53 | |
54 sqlite3 db test.db | |
55 sqlite3 db2 test.db | |
56 | |
57 do_test 2.0 { | |
58 execsql { | |
59 CREATE TABLE t1(a, b); | |
60 INSERT INTO t1 VALUES(1, 2); | |
61 PRAGMA journal_mode = wal; | |
62 } db2 | |
63 } {wal} | |
64 | |
65 do_catchsql_test 2.1 { | |
66 PRAGMA page_size = 4096; | |
67 VACUUM; | |
68 } {0 {}} | |
69 | |
70 db close | |
71 db2 close | |
72 forcedelete test.db test.db-wal | |
73 | |
74 sqlite3 db test.db | |
75 sqlite3 db2 test.db | |
76 | |
77 do_test 3.0 { | |
78 execsql { | |
79 PRAGMA journal_mode = wal; | |
80 CREATE TABLE t1(a, b); | |
81 INSERT INTO t1 VALUES(1, 2); | |
82 } db2 | |
83 } {wal} | |
84 | |
85 do_execsql_test 3.1 { | |
86 PRAGMA page_size = 4096; | |
87 SELECT name FROM sqlite_master; | |
88 } {t1} | |
89 | |
90 finish_test | |
OLD | NEW |