mirror of
https://github.com/sqlite/sqlite.git
synced 2025-09-11 08:30:57 +03:00
Modify the code for reading hot-journal files so that it can handle journals generated by versions 3.5.7 and earlier.
FossilOrigin-Name: b9170f2903c480bca2bdc986e98aaeadfdb9ad2b
This commit is contained in:
@@ -27,13 +27,14 @@ set testdir [file dirname $argv0]
|
||||
source $testdir/tester.tcl
|
||||
source $testdir/lock_common.tcl
|
||||
source $testdir/malloc_common.tcl
|
||||
db close
|
||||
|
||||
# Search for binaries to test against. Any executable files that match
|
||||
# our naming convention are assumed to be testfixture binaries to test
|
||||
# against.
|
||||
#
|
||||
set binaries [list]
|
||||
set pattern "[file tail [info nameofexec]]?*"
|
||||
set pattern "[file tail [info nameofexec]]*"
|
||||
foreach file [glob $pattern] {
|
||||
if {[file executable $file]} {lappend binaries $file}
|
||||
}
|
||||
@@ -52,24 +53,26 @@ foreach bin $binaries {
|
||||
puts "Testing against $bin - version [get_version $bin]"
|
||||
}
|
||||
|
||||
#set binaries testfixture
|
||||
proc do_backcompat_test {rv bin1 bin2 script} {
|
||||
|
||||
proc do_backcompat_test {rv binary script} {
|
||||
file delete -force test.db
|
||||
|
||||
if {$bin1 != ""} { set ::bc_chan1 [launch_testfixture $bin1] }
|
||||
set ::bc_chan2 [launch_testfixture $bin2]
|
||||
|
||||
if { $rv } {
|
||||
proc code1 {tcl} { testfixture $::bc_chan $tcl }
|
||||
proc code2 {tcl} { uplevel #0 $tcl }
|
||||
if {$bin1 != ""} { proc code2 {tcl} { testfixture $::bc_chan1 $tcl } }
|
||||
proc code1 {tcl} { testfixture $::bc_chan2 $tcl }
|
||||
} else {
|
||||
proc code1 {tcl} { uplevel #0 $tcl }
|
||||
proc code2 {tcl} { testfixture $::bc_chan $tcl }
|
||||
if {$bin1 != ""} { proc code1 {tcl} { testfixture $::bc_chan1 $tcl } }
|
||||
proc code2 {tcl} { testfixture $::bc_chan2 $tcl }
|
||||
}
|
||||
|
||||
proc sql1 sql { code1 [list db eval $sql] }
|
||||
proc sql2 sql { code2 [list db eval $sql] }
|
||||
|
||||
file delete -force test.db
|
||||
|
||||
set ::bc_chan [launch_testfixture $binary]
|
||||
code1 { sqlite3 db test.db }
|
||||
code2 { sqlite3 db test.db }
|
||||
|
||||
@@ -77,7 +80,8 @@ proc do_backcompat_test {rv binary script} {
|
||||
|
||||
catch { code1 { db close } }
|
||||
catch { code2 { db close } }
|
||||
catch { close $::bc_chan }
|
||||
catch { close $::bc_chan2 }
|
||||
catch { close $::bc_chan1 }
|
||||
}
|
||||
|
||||
array set ::incompatible [list]
|
||||
@@ -87,7 +91,7 @@ proc do_allbackcompat_test {script} {
|
||||
set nErr [set_test_counter errors]
|
||||
foreach dir {0 1} {
|
||||
|
||||
set ::bcname ".$dir.[string map {testfixture {}} $bin]."
|
||||
set ::bcname ".[string map {testfixture {}} $bin].$dir."
|
||||
|
||||
rename do_test _do_test
|
||||
proc do_test {nm sql res} {
|
||||
@@ -95,7 +99,7 @@ proc do_allbackcompat_test {script} {
|
||||
uplevel [list _do_test $nm $sql $res]
|
||||
}
|
||||
|
||||
do_backcompat_test $dir $bin $script
|
||||
do_backcompat_test $dir {} $bin $script
|
||||
|
||||
rename do_test {}
|
||||
rename _do_test do_test
|
||||
@@ -157,6 +161,11 @@ do_allbackcompat_test {
|
||||
# Test that one version can roll back a hot-journal file left in the
|
||||
# file-system by the other version.
|
||||
#
|
||||
# Each test case is named "backcompat-1.X...", where X is either 0 or
|
||||
# 1. If it is 0, then the current version creates a journal file that
|
||||
# the old versions try to read. Otherwise, if X is 1, then the old version
|
||||
# creates the journal file and we try to read it with the current version.
|
||||
#
|
||||
do_test backcompat-1.2.1 { sql1 {
|
||||
PRAGMA cache_size = 10;
|
||||
BEGIN;
|
||||
@@ -176,16 +185,25 @@ do_allbackcompat_test {
|
||||
UPDATE t1 SET a = randomblob(500);
|
||||
} } {}
|
||||
set data [read_file_system]
|
||||
|
||||
set f "test.db-journal[incr x]"
|
||||
file copy -force test.db-journal $f
|
||||
|
||||
do_test backcompat-1.2.4 { sql1 { COMMIT } } {}
|
||||
|
||||
set same [expr {[sql2 {SELECT md5sum(a), md5sum(b) FROM t1}] == $cksum2}]
|
||||
do_test backcompat-1.2.5 [list set {} $same] 0
|
||||
|
||||
code1 { db close }
|
||||
code2 { db close }
|
||||
write_file_system $data
|
||||
code1 { sqlite3 db test.db }
|
||||
code2 { sqlite3 db test.db }
|
||||
|
||||
set same [expr {[sql2 {SELECT md5sum(a), md5sum(b) FROM t1}] == $cksum2}]
|
||||
do_test backcompat-1.2.6 [list set {} $same] 1
|
||||
|
||||
do_test backcompat-1.2.7 { sql2 { PRAGMA integrity_check } } {ok}
|
||||
do_test backcompat-1.2.7 { sql1 { PRAGMA integrity_check } } {ok}
|
||||
do_test backcompat-1.2.8 { sql2 { PRAGMA integrity_check } } {ok}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user