/ Check-in [7999910e]
Login

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

Overview
Comment:Add tests for WAL mode to test/backcompat.test.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 7999910e85b1f24c5860425ba47e7ab10c22e887
User & Date: dan 2010-08-19 15:48:47
Context
2010-08-19
17:16
Fix backcompat.test so that it works with windows mandatory locking. check-in: 8d05f66d user: dan tags: trunk
15:48
Add tests for WAL mode to test/backcompat.test. check-in: 7999910e user: dan tags: trunk
15:12
Merge two leaves. check-in: b03091fc user: dan tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to test/backcompat.test.

87
88
89
90
91
92
93
94


95
96
97
98
99
100
101
...
139
140
141
142
143
144
145




146
147
148
149
150
151
152
...
202
203
204
205
206
207
208
209
210
211
212

213









































214
array set ::incompatible [list]
proc do_allbackcompat_test {script} {

  foreach bin $::binaries {
    set nErr [set_test_counter errors]
    foreach dir {0 1} {

      set ::bcname ".[string map {testfixture {}} $bin].$dir."



      rename do_test _do_test
      proc do_test {nm sql res} {
        set nm [regsub {\.} $nm $::bcname]
        uplevel [list _do_test $nm $sql $res]
      }

................................................................................
      write_file $f $d
    }
  }
}

#-------------------------------------------------------------------------
# Actual tests begin here.




#
do_allbackcompat_test {

  # Test that database files are backwards compatible.
  #
  do_test backcompat-1.1.1 { sql1 { 
    CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);
................................................................................

  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 { sql1 { PRAGMA integrity_check } } {ok}
  do_test backcompat-1.2.8 { sql2 { PRAGMA integrity_check } } {ok}
}

foreach k [lsort [array names ::incompatible]] {
  puts "ERROR: Detected incompatibility with version $k"
}











































finish_test







|
>
>







 







>
>
>
>







 







<

|

>

>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
...
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
...
208
209
210
211
212
213
214

215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
array set ::incompatible [list]
proc do_allbackcompat_test {script} {

  foreach bin $::binaries {
    set nErr [set_test_counter errors]
    foreach dir {0 1} {

      set bintag [string map {testfixture {}} $bin]
      if {$bintag == ""} {set bintag self}
      set ::bcname ".$bintag.$dir."

      rename do_test _do_test
      proc do_test {nm sql res} {
        set nm [regsub {\.} $nm $::bcname]
        uplevel [list _do_test $nm $sql $res]
      }

................................................................................
      write_file $f $d
    }
  }
}

#-------------------------------------------------------------------------
# Actual tests begin here.
#
# This first block of tests checks to see that the same database and 
# journal files can be used by old and new versions. WAL and wal-index
# files are tested separately below.
#
do_allbackcompat_test {

  # Test that database files are backwards compatible.
  #
  do_test backcompat-1.1.1 { sql1 { 
    CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);
................................................................................

  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 { sql1 { PRAGMA integrity_check } } {ok}
  do_test backcompat-1.2.8 { sql2 { PRAGMA integrity_check } } {ok}
}

foreach k [lsort [array names ::incompatible]] {
  puts "ERROR: Detected journal incompatibility with version $k"
}
unset ::incompatible


#-------------------------------------------------------------------------
# Test that WAL and wal-index files may be shared between different 
# SQLite versions.
#
do_allbackcompat_test {
  if {[code1 {sqlite3 -version}] >= "3.7.0"
   && [code2 {sqlite3 -version}] >= "3.7.0"
  } {

    do_test backcompat-2.1.1 { sql1 {
      PRAGMA journal_mode = WAL;
      CREATE TABLE t1(a PRIMARY KEY, b UNIQUE);
      INSERT INTO t1 VALUES('I', 1);
      INSERT INTO t1 VALUES('II', 2);
      INSERT INTO t1 VALUES('III', 3);
      SELECT * FROM t1;
    } } {wal I 1 II 2 III 3}
    do_test backcompat-2.1.2 { sql2 {
      SELECT * FROM t1;
    } } {I 1 II 2 III 3}

    set data [read_file_system]
    code1 {db close}
    code2 {db close}
    write_file_system $data
    code1 {sqlite3 db test.db}
    code2 {sqlite3 db test.db}

    # The WAL file now in the file-system was created by the [code1]
    # process. Check that the [code2] process can recover the log.
    #
    do_test backcompat-2.1.3 { sql2 {
      SELECT * FROM t1;
    } } {I 1 II 2 III 3}
    do_test backcompat-2.1.4 { sql1 {
      SELECT * FROM t1;
    } } {I 1 II 2 III 3}
  }
}

finish_test