/ Check-in [157feba1]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Add test for the code that detects an inconsistent pair of wal-index headers to wal2.test.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 157feba10f7ac01eecf79715c44bb16c98958280
User & Date: dan 2010-06-04 12:22:35
Context
2010-06-04
15:59
Add an English language error message to corresponding to SQLITE_PROTOCOL. "locking protocol". check-in: ca327e32 user: dan tags: trunk
12:22
Add test for the code that detects an inconsistent pair of wal-index headers to wal2.test. check-in: 157feba1 user: dan tags: trunk
11:56
If an attempt to sync the database file as part of a checkpoint fails, do not update the shared "nBackfill" variable. Otherwise, another process could wrap the log and overwrite content before it is synced into the database. check-in: b813233d user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to test/wal2.test.

   740    740   do_test wal2-7.1.3 {
   741    741     sqlite3 db2 test2.db
   742    742     execsql { PRAGMA wal_checkpoint } db2
   743    743     execsql { SELECT * FROM sqlite_master } db2
   744    744   } {}
   745    745   db close
   746    746   db2 close
   747         -
   748    747   file delete -force test.db test.db-wal test.db-journal
   749    748   do_test wal2-8.1.2 {
   750    749     sqlite3 db test.db
   751    750     execsql {
   752    751       PRAGMA auto_vacuum=OFF;
   753    752       PRAGMA page_size = 1024;
   754    753       PRAGMA journal_mode = WAL;
................................................................................
   784    783     }
   785    784   } {}
   786    785   do_test wal2-8.1.4 {
   787    786     sqlite3 db2 test.db
   788    787     execsql { SELECT * FROM t2 }
   789    788   } {goodbye}
   790    789   db2 close
          790  +db close
          791  +
          792  +#-------------------------------------------------------------------------
          793  +# Test that even if the checksums for both are valid, if the two copies
          794  +# of the wal-index header in the wal-index do not match, the client
          795  +# runs (or at least tries to run) database recovery.
          796  +#
          797  +
          798  +proc get_name {method args} { set ::filename [lindex $args 0] }
          799  +testvfs tvfs
          800  +tvfs script get_name
          801  +tvfs filter xShmOpen
          802  +
          803  +file delete -force test.db test.db-wal test.db-journal
          804  +do_test wal2-9.1 {
          805  +  sqlite3 db test.db -vfs tvfs
          806  +  execsql {
          807  +    PRAGMA journal_mode = WAL;
          808  +    CREATE TABLE x(y);
          809  +    INSERT INTO x VALUES('Barton');
          810  +    INSERT INTO x VALUES('Deakin');
          811  +  }
          812  +  set wal_index_hdr1 [string range [tvfs shm $::filename] 0 39]
          813  +  execsql { INSERT INTO x VALUES('Watson') }
          814  +} {}
          815  +do_test wal2-9.2 {
          816  +  sqlite3 db2 test.db -vfs tvfs
          817  +  execsql { SELECT * FROM x } db2
          818  +} {Barton Deakin Watson}
          819  +do_test wal2-9.3 {
          820  +  set wal_index_hdr2 [string range [tvfs shm $::filename] 0 39]
          821  +  set content [string range [tvfs shm $::filename] 80 end]
          822  +  set w [binary format a*a*a* $wal_index_hdr1 $wal_index_hdr1 $content]
          823  +  tvfs shm $::filename $w
          824  +  execsql { SELECT * FROM x } db2
          825  +} {Barton Deakin}
          826  +do_test wal2-9.4 {
          827  +  set w [binary format a*a*a* $wal_index_hdr2 $wal_index_hdr2 $content]
          828  +  tvfs shm $::filename $w
          829  +  execsql { SELECT * FROM x } db2
          830  +} {Barton Deakin Watson}
          831  +do_test wal2-9.5 {
          832  +  set w [binary format a*a*a* $wal_index_hdr1 $wal_index_hdr2 $content]
          833  +  tvfs shm $::filename $w
          834  +  execsql { SELECT * FROM x } db2
          835  +} {Barton Deakin Watson}
          836  +do_test wal2-9.6 {
          837  +  set w [binary format a*a*a* $wal_index_hdr2 $wal_index_hdr1 $content]
          838  +  tvfs shm $::filename $w
          839  +  execsql { SELECT * FROM x } db2
          840  +} {Barton Deakin Watson}
          841  +do_test wal2-9.7 {
          842  +  set w [binary format a*a*a* $wal_index_hdr1 $wal_index_hdr1 $content]
          843  +  tvfs shm $::filename $w
          844  +  execsql { SELECT * FROM x } db2
          845  +} {Barton Deakin}
   791    846   
          847  +db2 close
          848  +db close
   792    849   
   793    850   finish_test