OLD | NEW |
1 # 2010 May 24 | 1 # 2010 May 24 |
2 # | 2 # |
3 # The author disclaims copyright to this source code. In place of | 3 # The author disclaims copyright to this source code. In place of |
4 # a legal notice, here is a blessing: | 4 # a legal notice, here is a blessing: |
5 # | 5 # |
6 # May you do good and not evil. | 6 # May you do good and not evil. |
7 # May you find forgiveness for yourself and forgive others. | 7 # May you find forgiveness for yourself and forgive others. |
8 # May you share freely, never taking more than you give. | 8 # May you share freely, never taking more than you give. |
9 # | 9 # |
10 #*********************************************************************** | 10 #*********************************************************************** |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 | 327 |
328 sqlite3 db2 test2.db | 328 sqlite3 db2 test2.db |
329 execsql { | 329 execsql { |
330 PRAGMA integrity_check; | 330 PRAGMA integrity_check; |
331 SELECT count(*) FROM t1; | 331 SELECT count(*) FROM t1; |
332 } db2 | 332 } db2 |
333 } {ok 256} | 333 } {ok 256} |
334 catch { db close } | 334 catch { db close } |
335 catch { db2 close } | 335 catch { db2 close } |
336 | 336 |
337 #------------------------------------------------------------------------- | |
338 # Test case walcksum-3.* tests that the checksum calculation detects single | |
339 # byte changes to frame or frame-header data and considers the frame | |
340 # invalid as a result. | |
341 # | |
342 do_test walcksum-3.1 { | |
343 forcedelete test.db test.db-wal test.db-journal | |
344 sqlite3 db test.db | |
345 | |
346 execsql { | |
347 PRAGMA synchronous = NORMAL; | |
348 PRAGMA page_size = 1024; | |
349 CREATE TABLE t1(a, b); | |
350 INSERT INTO t1 VALUES(1, randomblob(300)); | |
351 INSERT INTO t1 VALUES(2, randomblob(300)); | |
352 PRAGMA journal_mode = WAL; | |
353 INSERT INTO t1 VALUES(3, randomblob(300)); | |
354 } | |
355 | |
356 file size test.db-wal | |
357 } [wal_file_size 1 1024] | |
358 do_test walcksum-3.2 { | |
359 forcecopy test.db-wal test2.db-wal | |
360 forcecopy test.db test2.db | |
361 sqlite3 db2 test2.db | |
362 execsql { SELECT a FROM t1 } db2 | |
363 } {1 2 3} | |
364 db2 close | |
365 forcecopy test.db test2.db | |
366 | |
367 | |
368 foreach incr {1 2 3 20 40 60 80 100 120 140 160 180 200 220 240 253 254 255} { | |
369 do_test walcksum-3.3.$incr { | |
370 set FAIL 0 | |
371 for {set iOff 0} {$iOff < [wal_file_size 1 1024]} {incr iOff} { | |
372 | |
373 forcecopy test.db-wal test2.db-wal | |
374 set fd [open test2.db-wal r+] | |
375 fconfigure $fd -encoding binary | |
376 fconfigure $fd -translation binary | |
377 | |
378 seek $fd $iOff | |
379 binary scan [read $fd 1] c x | |
380 seek $fd $iOff | |
381 puts -nonewline $fd [binary format c [expr {($x+$incr)&0xFF}]] | |
382 close $fd | |
383 | |
384 sqlite3 db2 test2.db | |
385 if { [execsql { SELECT a FROM t1 } db2] != "1 2" } {set FAIL 1} | |
386 db2 close | |
387 } | |
388 set FAIL | |
389 } {0} | |
390 } | |
391 | 337 |
392 finish_test | 338 finish_test |
OLD | NEW |