SQLite

Check-in [157feba10f]
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
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 157feba10f7ac01eecf79715c44bb16c98958280
User & Date: dan 2010-06-04 12:22:35.000
Context
2010-06-04
15:59
Add an English language error message to corresponding to SQLITE_PROTOCOL. "locking protocol". (check-in: ca327e32cf 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: 157feba10f 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: b813233d76 user: dan tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to test/wal2.test.
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
do_test wal2-7.1.3 {
  sqlite3 db2 test2.db
  execsql { PRAGMA wal_checkpoint } db2
  execsql { SELECT * FROM sqlite_master } db2
} {}
db close
db2 close

file delete -force test.db test.db-wal test.db-journal
do_test wal2-8.1.2 {
  sqlite3 db test.db
  execsql {
    PRAGMA auto_vacuum=OFF;
    PRAGMA page_size = 1024;
    PRAGMA journal_mode = WAL;







<







740
741
742
743
744
745
746

747
748
749
750
751
752
753
do_test wal2-7.1.3 {
  sqlite3 db2 test2.db
  execsql { PRAGMA wal_checkpoint } db2
  execsql { SELECT * FROM sqlite_master } db2
} {}
db close
db2 close

file delete -force test.db test.db-wal test.db-journal
do_test wal2-8.1.2 {
  sqlite3 db test.db
  execsql {
    PRAGMA auto_vacuum=OFF;
    PRAGMA page_size = 1024;
    PRAGMA journal_mode = WAL;
784
785
786
787
788
789
790

791




792





















































793
  }
} {}
do_test wal2-8.1.4 {
  sqlite3 db2 test.db
  execsql { SELECT * FROM t2 }
} {goodbye}
db2 close




























































finish_test







>

>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
  }
} {}
do_test wal2-8.1.4 {
  sqlite3 db2 test.db
  execsql { SELECT * FROM t2 }
} {goodbye}
db2 close
db close

#-------------------------------------------------------------------------
# Test that even if the checksums for both are valid, if the two copies
# of the wal-index header in the wal-index do not match, the client
# runs (or at least tries to run) database recovery.
#

proc get_name {method args} { set ::filename [lindex $args 0] }
testvfs tvfs
tvfs script get_name
tvfs filter xShmOpen

file delete -force test.db test.db-wal test.db-journal
do_test wal2-9.1 {
  sqlite3 db test.db -vfs tvfs
  execsql {
    PRAGMA journal_mode = WAL;
    CREATE TABLE x(y);
    INSERT INTO x VALUES('Barton');
    INSERT INTO x VALUES('Deakin');
  }
  set wal_index_hdr1 [string range [tvfs shm $::filename] 0 39]
  execsql { INSERT INTO x VALUES('Watson') }
} {}
do_test wal2-9.2 {
  sqlite3 db2 test.db -vfs tvfs
  execsql { SELECT * FROM x } db2
} {Barton Deakin Watson}
do_test wal2-9.3 {
  set wal_index_hdr2 [string range [tvfs shm $::filename] 0 39]
  set content [string range [tvfs shm $::filename] 80 end]
  set w [binary format a*a*a* $wal_index_hdr1 $wal_index_hdr1 $content]
  tvfs shm $::filename $w
  execsql { SELECT * FROM x } db2
} {Barton Deakin}
do_test wal2-9.4 {
  set w [binary format a*a*a* $wal_index_hdr2 $wal_index_hdr2 $content]
  tvfs shm $::filename $w
  execsql { SELECT * FROM x } db2
} {Barton Deakin Watson}
do_test wal2-9.5 {
  set w [binary format a*a*a* $wal_index_hdr1 $wal_index_hdr2 $content]
  tvfs shm $::filename $w
  execsql { SELECT * FROM x } db2
} {Barton Deakin Watson}
do_test wal2-9.6 {
  set w [binary format a*a*a* $wal_index_hdr2 $wal_index_hdr1 $content]
  tvfs shm $::filename $w
  execsql { SELECT * FROM x } db2
} {Barton Deakin Watson}
do_test wal2-9.7 {
  set w [binary format a*a*a* $wal_index_hdr1 $wal_index_hdr1 $content]
  tvfs shm $::filename $w
  execsql { SELECT * FROM x } db2
} {Barton Deakin}

db2 close
db close

finish_test