AryaWu/sqlite
0
1# 2010 September 202#3# The author disclaims copyright to this source code. In place of4# a legal notice, here is a blessing:5#6# May you do good and not evil.7# May you find forgiveness for yourself and forgive others.8# May you share freely, never taking more than you give.9#10#***********************************************************************11# This file implements regression tests for SQLite library.12#13# This file implements tests to verify that ticket [313723c356] has been14# fixed. 15#16 17set testdir [file dirname $argv0]18source $testdir/tester.tcl19source $testdir/malloc_common.tcl20 21if {![wal_is_capable]} { finish_test ; return }22 23do_execsql_test tkt-313723c356.1 {24 PRAGMA page_size = 1024;25 PRAGMA journal_mode = WAL;26 CREATE TABLE t1(a, b);27 CREATE INDEX i1 ON t1(a, b);28 INSERT INTO t1 VALUES(randomblob(400), randomblob(400));29 INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM t1;30 INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM t1;31 INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM t1;32 INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM t1;33} {wal}34faultsim_save_and_close35 36do_faultsim_test tkt-313723c356.2 -faults shmerr* -prep {37 faultsim_restore_and_reopen38 sqlite3 db2 test.db39 db eval { SELECT * FROM t1 }40 db2 eval { UPDATE t1 SET a = randomblob(399) }41 db2 close42} -body {43 # At this point, the cache contains all of table t1 and none of index i1. The44 # cache is out of date. When the bug existed and the right xShmLock() fails45 # in the following statement, the internal cache of the WAL header was46 # being updated, but the contents of the page-cache not flushed. This causes47 # the integrity-check in the "-test" code to fail, as it is comparing the48 # cached (out-of-date) version of table t1 with the on disk (up-to-date)49 # version of index i1.50 #51 execsql { SELECT min(rowid) FROM t1 }52} -test {53 faultsim_test_result {0 1}54 faultsim_integrity_check55}56 57finish_test58 