mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Continuing work on journal_mode. Journal_mode=persist now appears to be
working, though additional testing would be welcomed. (CVS 5033) FossilOrigin-Name: 277e4099cee9105e1801a6d7f5d477f0d2efa858
This commit is contained in:
156
test/jrnlmode.test
Normal file
156
test/jrnlmode.test
Normal file
@ -0,0 +1,156 @@
|
||||
# 2008 April 17
|
||||
#
|
||||
# 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 these tests is the journal mode pragma.
|
||||
#
|
||||
# $Id: jrnlmode.test,v 1.1 2008/04/19 20:34:19 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
ifcapable {!pager_pragmas} {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
# Test cases jrnlmode-1.X test the PRAGMA logic.
|
||||
#
|
||||
do_test jrnlmode-1.0 {
|
||||
execsql {
|
||||
PRAGMA journal_mode;
|
||||
PRAGMA main.journal_mode;
|
||||
PRAGMA temp.journal_mode;
|
||||
}
|
||||
} [list delete delete delete]
|
||||
do_test jrnlmode-1.1 {
|
||||
execsql {
|
||||
PRAGMA journal_mode = persist;
|
||||
}
|
||||
} {persist}
|
||||
do_test jrnlmode-1.2 {
|
||||
execsql {
|
||||
PRAGMA journal_mode;
|
||||
PRAGMA main.journal_mode;
|
||||
PRAGMA temp.journal_mode;
|
||||
}
|
||||
} [list persist persist persist]
|
||||
do_test jrnlmode-1.4 {
|
||||
execsql {
|
||||
PRAGMA journal_mode = off;
|
||||
}
|
||||
} {off}
|
||||
do_test jrnlmode-1.5 {
|
||||
execsql {
|
||||
PRAGMA journal_mode;
|
||||
PRAGMA main.journal_mode;
|
||||
PRAGMA temp.journal_mode;
|
||||
}
|
||||
} {off off off}
|
||||
do_test jrnlmode-1.6 {
|
||||
execsql {
|
||||
PRAGMA journal_mode = delete;
|
||||
}
|
||||
} {delete}
|
||||
do_test jrnlmode-1.7 {
|
||||
execsql {
|
||||
PRAGMA journal_mode;
|
||||
PRAGMA main.journal_mode;
|
||||
PRAGMA temp.journal_mode;
|
||||
}
|
||||
} {delete delete delete}
|
||||
do_test jrnlmode-1.8 {
|
||||
execsql {
|
||||
PRAGMA journal_mode = off;
|
||||
PRAGMA journal_mode = invalid;
|
||||
}
|
||||
} {off off}
|
||||
ifcapable attach {
|
||||
do_test jrnlmode-1.9 {
|
||||
execsql {
|
||||
PRAGMA journal_mode = persist;
|
||||
ATTACH ':memory:' as aux1;
|
||||
}
|
||||
execsql {
|
||||
PRAGMA main.journal_mode;
|
||||
PRAGMA aux1.journal_mode;
|
||||
}
|
||||
} {persist persist}
|
||||
do_test jrnlmode-1.10 {
|
||||
execsql {
|
||||
PRAGMA main.journal_mode = off;
|
||||
}
|
||||
execsql {
|
||||
PRAGMA main.journal_mode;
|
||||
PRAGMA temp.journal_mode;
|
||||
PRAGMA aux1.journal_mode;
|
||||
}
|
||||
} {off persist persist}
|
||||
do_test jrnlmode-1.11 {
|
||||
execsql {
|
||||
PRAGMA journal_mode;
|
||||
}
|
||||
} {persist}
|
||||
do_test jrnlmode-1.12 {
|
||||
execsql {
|
||||
ATTACH ':memory:' as aux2;
|
||||
}
|
||||
execsql {
|
||||
PRAGMA main.journal_mode;
|
||||
PRAGMA aux1.journal_mode;
|
||||
PRAGMA aux2.journal_mode;
|
||||
}
|
||||
} {off persist persist}
|
||||
do_test jrnlmode-1.11 {
|
||||
execsql {
|
||||
PRAGMA aux1.journal_mode = delete;
|
||||
}
|
||||
execsql {
|
||||
PRAGMA main.journal_mode;
|
||||
PRAGMA aux1.journal_mode;
|
||||
PRAGMA aux2.journal_mode;
|
||||
}
|
||||
} {off delete persist}
|
||||
do_test jrnlmode-1.12 {
|
||||
execsql {
|
||||
PRAGMA journal_mode = delete;
|
||||
}
|
||||
execsql {
|
||||
PRAGMA main.journal_mode;
|
||||
PRAGMA temp.journal_mode;
|
||||
PRAGMA aux1.journal_mode;
|
||||
PRAGMA aux2.journal_mode;
|
||||
}
|
||||
} {delete delete delete delete}
|
||||
do_test jrnlmode-1.13 {
|
||||
execsql {
|
||||
ATTACH ':memory:' as aux3;
|
||||
}
|
||||
execsql {
|
||||
PRAGMA main.journal_mode;
|
||||
PRAGMA temp.journal_mode;
|
||||
PRAGMA aux1.journal_mode;
|
||||
PRAGMA aux2.journal_mode;
|
||||
PRAGMA aux3.journal_mode;
|
||||
}
|
||||
} {delete delete delete delete delete}
|
||||
|
||||
do_test jrnlmode-1.99 {
|
||||
execsql {
|
||||
DETACH aux1;
|
||||
DETACH aux2;
|
||||
DETACH aux3;
|
||||
}
|
||||
} {}
|
||||
}
|
||||
|
||||
|
||||
finish_test
|
58
test/jrnlmode2.test
Normal file
58
test/jrnlmode2.test
Normal file
@ -0,0 +1,58 @@
|
||||
# 2007 March 26
|
||||
#
|
||||
# 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 runs the tests in the file ioerr.test with
|
||||
# persistent journal mode enabled.
|
||||
#
|
||||
# $Id: jrnlmode2.test,v 1.1 2008/04/19 20:34:19 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
ifcapable {!pager_pragmas} {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
rename finish_test really_finish_test2
|
||||
proc finish_test {} {}
|
||||
set ISQUICK 1
|
||||
|
||||
rename sqlite3 real_sqlite3
|
||||
proc sqlite3 {args} {
|
||||
set r [eval "real_sqlite3 $args"]
|
||||
if { [llength $args] == 2 } {
|
||||
[lindex $args 0] eval {PRAGMA journal_mode = persist}
|
||||
}
|
||||
set r
|
||||
}
|
||||
|
||||
rename do_test really_do_test
|
||||
proc do_test {args} {
|
||||
set sc [concat really_do_test "jrlnmode2-[lindex $args 0]" \
|
||||
[lrange $args 1 end]]
|
||||
eval $sc
|
||||
}
|
||||
|
||||
source $testdir/vacuum.test
|
||||
source $testdir/rollback.test
|
||||
source $testdir/select1.test
|
||||
source $testdir/select2.test
|
||||
source $testdir/trans.test
|
||||
|
||||
|
||||
rename sqlite3 ""
|
||||
rename real_sqlite3 sqlite3
|
||||
rename finish_test ""
|
||||
rename really_finish_test2 finish_test
|
||||
rename do_test ""
|
||||
rename really_do_test do_test
|
||||
finish_test
|
55
test/jrnlmode3.test
Normal file
55
test/jrnlmode3.test
Normal file
@ -0,0 +1,55 @@
|
||||
# 2007 March 26
|
||||
#
|
||||
# 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 runs the tests in the file ioerr.test with
|
||||
# persistent journal mode enabled.
|
||||
#
|
||||
# $Id: jrnlmode3.test,v 1.1 2008/04/19 20:34:19 drh Exp $
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
|
||||
ifcapable {!pager_pragmas} {
|
||||
finish_test
|
||||
return
|
||||
}
|
||||
|
||||
rename finish_test really_finish_test2
|
||||
proc finish_test {} {}
|
||||
set ISQUICK 1
|
||||
|
||||
rename sqlite3 real_sqlite3
|
||||
proc sqlite3 {args} {
|
||||
set r [eval "real_sqlite3 $args"]
|
||||
if { [llength $args] == 2 } {
|
||||
[lindex $args 0] eval {PRAGMA journal_mode = persist}
|
||||
}
|
||||
set r
|
||||
}
|
||||
|
||||
rename do_test really_do_test
|
||||
proc do_test {args} {
|
||||
set sc [concat really_do_test "jrlnmode2-[lindex $args 0]" \
|
||||
[lrange $args 1 end]]
|
||||
eval $sc
|
||||
}
|
||||
|
||||
source $testdir/malloc.test
|
||||
source $testdir/ioerr.test
|
||||
|
||||
|
||||
rename sqlite3 ""
|
||||
rename real_sqlite3 sqlite3
|
||||
rename finish_test ""
|
||||
rename really_finish_test2 finish_test
|
||||
rename do_test ""
|
||||
rename really_do_test do_test
|
||||
finish_test
|
@ -6,7 +6,7 @@
|
||||
#***********************************************************************
|
||||
# This file runs all tests.
|
||||
#
|
||||
# $Id: quick.test,v 1.77 2008/04/11 14:56:53 drh Exp $
|
||||
# $Id: quick.test,v 1.78 2008/04/19 20:34:19 drh Exp $
|
||||
|
||||
proc lshift {lvar} {
|
||||
upvar $lvar l
|
||||
@ -54,6 +54,7 @@ set EXCLUDE {
|
||||
fuzz.test
|
||||
fuzz_malloc.test
|
||||
in2.test
|
||||
jrnlmode3.test
|
||||
loadext.test
|
||||
mallocAll.test
|
||||
malloc.test
|
||||
|
@ -11,7 +11,7 @@
|
||||
# This file implements regression tests for SQLite library. The
|
||||
# focus of this script is database locks.
|
||||
#
|
||||
# $Id: trans.test,v 1.37 2007/09/12 17:01:45 danielk1977 Exp $
|
||||
# $Id: trans.test,v 1.38 2008/04/19 20:34:19 drh Exp $
|
||||
|
||||
|
||||
set testdir [file dirname $argv0]
|
||||
@ -794,17 +794,35 @@ puts $fd {
|
||||
sqlite_abort
|
||||
}
|
||||
close $fd
|
||||
file copy -force test.db test.db-bu1
|
||||
do_test trans-8.1 {
|
||||
catch {exec [info nameofexec] test.tcl}
|
||||
file copy -force test.db test.db-bu2
|
||||
file copy -force test.db-journal test.db-bu2-journal
|
||||
execsql {SELECT md5sum(x,y,z) FROM t2}
|
||||
} $checksum
|
||||
do_test trans-8.2 {
|
||||
execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master}
|
||||
} $checksum2
|
||||
integrity_check trans-8.3
|
||||
set fd [open test.tcl w]
|
||||
puts $fd {
|
||||
sqlite3 db test.db
|
||||
db eval {
|
||||
PRAGMA journal_mode=persist;
|
||||
PRAGMA default_cache_size=20;
|
||||
BEGIN;
|
||||
CREATE TABLE t3 AS SELECT * FROM t2;
|
||||
DELETE FROM t2;
|
||||
}
|
||||
sqlite_abort
|
||||
}
|
||||
close $fd
|
||||
do_test trans-8.4 {
|
||||
catch {exec [info nameofexec] test.tcl}
|
||||
execsql {SELECT md5sum(x,y,z) FROM t2}
|
||||
} $checksum
|
||||
do_test trans-8.5 {
|
||||
execsql {SELECT md5sum(type,name,tbl_name,rootpage,sql) FROM sqlite_master}
|
||||
} $checksum2
|
||||
integrity_check trans-8.6
|
||||
|
||||
# In the following sequence of tests, compute the MD5 sum of the content
|
||||
# of a table, make lots of modifications to that table, then do a rollback.
|
||||
|
@ -6,7 +6,7 @@
|
||||
#***********************************************************************
|
||||
# This file runs all tests.
|
||||
#
|
||||
# $Id: veryquick.test,v 1.2 2008/04/10 13:33:18 drh Exp $
|
||||
# $Id: veryquick.test,v 1.3 2008/04/19 20:34:19 drh Exp $
|
||||
|
||||
proc lshift {lvar} {
|
||||
upvar $lvar l
|
||||
@ -64,6 +64,7 @@ set EXCLUDE {
|
||||
interrupt.test
|
||||
ioerr.test
|
||||
ioerr2.test
|
||||
jrnlmode3.test
|
||||
loadext.test
|
||||
mallocAll.test
|
||||
malloc.test
|
||||
|
Reference in New Issue
Block a user