sqlite/test/walhook.test
drh 833bf968e3 Rename the sqlite3_log_hook() to sqlite3_wal_hook(). Added comments to
wal.h.

FossilOrigin-Name: bbc385111b19071e20fe963fab814262c815b3e9
2010-04-28 14:42:19 +00:00

73 lines
1.7 KiB
Plaintext

# 2010 April 19
#
# The author disclaims copyright to this source code. In place of
# a legal notice, here is a blessing:
#
# May you do good and not evil.
# May you find forgiveness for yourself and forgive others.
# May you share freely, never taking more than you give.
#
#***********************************************************************
# This file implements regression tests for SQLite library. The
# focus of this file is testing the operation of the library in
# "PRAGMA journal_mode=WAL" mode.
#
set testdir [file dirname $argv0]
source $testdir/tester.tcl
proc sqlite3_wal {args} {
eval sqlite3 $args
[lindex $args 0] eval {
PRAGMA journal_mode = wal;
PRAGMA synchronous = normal;
PRAGMA page_size = 1024;
}
}
sqlite3_wal db test.db
db wal_hook wal_hook
set ::wal_hook [list]
proc wal_hook {zDb nEntry} {
lappend ::wal_hook $zDb $nEntry
return 0
}
do_test walhook-1.1 {
execsql { CREATE TABLE t1(i PRIMARY KEY, j) }
set ::wal_hook
} {main 3}
do_test walhook-1.2 {
set ::wal_hook [list]
execsql { INSERT INTO t1 VALUES(1, 'one') }
set ::wal_hook
} {main 5}
do_test walhook-1.3 {
proc wal_hook {args} { return 1 }
execsql { INSERT INTO t1 VALUES(2, 'two') }
file size test.db
} [expr 3*1024]
do_test walhook-1.4 {
proc wal_hook {zDb nEntry} {
execsql { PRAGMA checkpoint }
return 0
}
execsql { CREATE TABLE t2(a, b) }
file size test.db
} [expr 4*1024]
do_test walhook-1.5 {
sqlite3_wal db2 test.db
proc wal_hook {zDb nEntry} {
execsql { PRAGMA checkpoint } db2
return 0
}
execsql { CREATE TABLE t3(a PRIMARY KEY, b) }
file size test.db
} [expr 6*1024]
catch { db2 close }
catch { db close }
finish_test