blob: 6f2813b6181c791cf9463b56fb02775cf5b02200 [file] [log] [blame]
dan8d22a172010-04-19 18:03:51 +00001# 2010 April 19
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
16set testdir [file dirname $argv0]
17source $testdir/tester.tcl
18
19proc sqlite3_wal {args} {
20 eval sqlite3 $args
21 [lindex $args 0] eval {
22 PRAGMA journal_mode = wal;
23 PRAGMA synchronous = normal;
24 PRAGMA page_size = 1024;
25 }
26}
27sqlite3_wal db test.db
28db log_hook log_hook
29
30set ::log_hook [list]
31proc log_hook {zDb nEntry} {
32 lappend ::log_hook $zDb $nEntry
33 return 0
34}
35
36do_test walhook-1.1 {
37 execsql { CREATE TABLE t1(i PRIMARY KEY, j) }
38 set ::log_hook
39} {main 3}
40do_test walhook-1.2 {
41 set ::log_hook [list]
42 execsql { INSERT INTO t1 VALUES(1, 'one') }
43 set ::log_hook
44} {main 5}
45do_test walhook-1.3 {
46 proc log_hook {args} { return 1 }
47 execsql { INSERT INTO t1 VALUES(2, 'two') }
48 file size test.db
49} [expr 3*1024]
50
51do_test walhook-1.4 {
52 proc log_hook {zDb nEntry} {
53 execsql { PRAGMA checkpoint }
54 return 0
55 }
56 execsql { CREATE TABLE t2(a, b) }
57 file size test.db
58} [expr 4*1024]
59
60do_test walhook-1.5 {
61 sqlite3_wal db2 test.db
62 proc log_hook {zDb nEntry} {
63 execsql { PRAGMA checkpoint } db2
64 return 0
65 }
66 execsql { CREATE TABLE t3(a PRIMARY KEY, b) }
67 file size test.db
68} [expr 6*1024]
69
70catch { db2 close }
71catch { db close }
72finish_test
73