]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Modify the code for reading hot-journal files so that it can handle journals generate...
authordan <dan@noemail.net>
Thu, 19 Aug 2010 15:11:34 +0000 (15:11 +0000)
committerdan <dan@noemail.net>
Thu, 19 Aug 2010 15:11:34 +0000 (15:11 +0000)
FossilOrigin-Name: b9170f2903c480bca2bdc986e98aaeadfdb9ad2b

manifest
manifest.uuid
src/pager.c
test/backcompat.test

index 177930e81e6ba7c0cbe3fdc55f73eecfea92428a..8e4f454a0cf70a177e3b56a9c1780ef82da360f7 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Add\snew\stest\sscript\sbackcompat.test,\sfor\stesting\sdatabase/journal/wal\sfile\scompatibility\sagainst\sprevious\sversions.
-D 2010-08-19T11:05:54
+C Modify\sthe\scode\sfor\sreading\shot-journal\sfiles\sso\sthat\sit\scan\shandle\sjournals\sgenerated\sby\sversions\s3.5.7\sand\searlier.
+D 2010-08-19T15:11:34
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in ec08dc838fd8110fe24c92e5130bcd91cbb1ff2e
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -156,7 +156,7 @@ F src/os_common.h a8f95b81eca8a1ab8593d23e94f8a35f35d4078f
 F src/os_os2.c 72d0b2e562952a2464308c4ce5f7913ac10bef3e
 F src/os_unix.c 11194cbcf6a57456e58022dc537ab8c3497d9bb9
 F src/os_win.c 51cb62f76262d961ea4249489383d714501315a7
-F src/pager.c 8b73d7f47d0143f7b9571125c6f897b8f1c59435
+F src/pager.c 3e9815178b2f3ffcf9f5a6b7d40212be77b4f5bf
 F src/pager.h ef8c8f71ab022cc2fff768a1175dd32355be9dcd
 F src/parse.y 12b7ebd61ea54f0e1b1083ff69cc2c8ce9353d58
 F src/pcache.c 1e9aa2dbc0845b52e1b51cc39753b6d1e041cb07
@@ -259,7 +259,7 @@ F test/autoindex1.test 7df441bf0e7a88644eb80993339dbf1db3a12c68
 F test/autovacuum.test bb7c0885e6f8f1d633045de48f2b66082162766d
 F test/autovacuum_ioerr2.test 598b0663074d3673a9c1bc9a16e80971313bafe6
 F test/avtrans.test 0252654f4295ddda3b2cce0e894812259e655a85
-F test/backcompat.test 5bf6bd795d9a0ec3c68ba8483c35c6fdab3a85a8
+F test/backcompat.test a64138b3f00bcb6af91fb609e805b03a7d74e690
 F test/backup.test 200e64bd91244b73ca8094bc1e03dfc83cc94c2e
 F test/backup2.test b7c69f937c912e85ac8a5dbd1e1cf290302b2d49
 F test/backup_ioerr.test 1f012e692f42c0442ae652443258f70e9f20fa38
@@ -845,7 +845,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
 F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
-P e127192d106bd7e036caacf01bf7725eeaa85dbe
-R 483010ace30045b3aabe4559c5204690
+P 8804f4989d157707911488781109ce0641c0ad0b
+R 8a8db0863e0d33ddc8ea68f9c11cd0ea
 U dan
-Z f27bf406a20d9eac5bd8544c4021a73e
+Z 9fa359ca155f08d9a7ed0d63491f2a4b
index 275f03d03810d85dbd2a180548fce8c84c105c93..8ea764cbed1dc01a03e94d3a497f46838f17e05e 100644 (file)
@@ -1 +1 @@
-8804f4989d157707911488781109ce0641c0ad0b
\ No newline at end of file
+b9170f2903c480bca2bdc986e98aaeadfdb9ad2b
\ No newline at end of file
index 04b7c82754113803e94ab42e6ee50e4de03230f1..df5150c7a3cd874e22840fa2293684e80c10fd88 100644 (file)
@@ -1509,6 +1509,14 @@ static int readJournalHdr(
       return rc;
     }
 
+    /* Versions of SQLite prior to 3.5.8 set the page-size field of the
+    ** journal header to zero. In this case, assume that the Pager.pageSize
+    ** variable is already set to the correct page size.
+    */
+    if( iPageSize==0 ){
+      iPageSize = pPager->pageSize;
+    }
+
     /* Check that the values read from the page-size and sector-size fields
     ** are within range. To be 'in range', both values need to be a power
     ** of two greater than or equal to 512 or 32, and not greater than their 
index a39d6cbac8e05f7ba0399c903a90a359a400b877..5c9a020ab311a8e45d20ae899bfbbeba36cd817c 100644 (file)
@@ -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}
 }