tkt-313723c356.test 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # 2010 September 20
  2. #
  3. # The author disclaims copyright to this source code. In place of
  4. # 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 been
  14. # fixed.
  15. #
  16. set testdir [file dirname $argv0]
  17. source $testdir/tester.tcl
  18. source $testdir/malloc_common.tcl
  19. ifcapable !wal { finish_test ; return }
  20. do_execsql_test tkt-313723c356.1 {
  21. PRAGMA page_size = 1024;
  22. PRAGMA journal_mode = WAL;
  23. CREATE TABLE t1(a, b);
  24. CREATE INDEX i1 ON t1(a, b);
  25. INSERT INTO t1 VALUES(randomblob(400), randomblob(400));
  26. INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM t1;
  27. INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM t1;
  28. INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM t1;
  29. INSERT INTO t1 SELECT randomblob(400), randomblob(400) FROM t1;
  30. } {wal}
  31. faultsim_save_and_close
  32. do_faultsim_test tkt-313723c356.2 -faults shmerr* -prep {
  33. faultsim_restore_and_reopen
  34. sqlite3 db2 test.db
  35. db eval { SELECT * FROM t1 }
  36. db2 eval { UPDATE t1 SET a = randomblob(399) }
  37. db2 close
  38. } -body {
  39. # At this point, the cache contains all of table t1 and none of index i1. The
  40. # cache is out of date. When the bug existed and the right xShmLock() fails
  41. # in the following statement, the internal cache of the WAL header was
  42. # being updated, but the contents of the page-cache not flushed. This causes
  43. # the integrity-check in the "-test" code to fail, as it is comparing the
  44. # cached (out-of-date) version of table t1 with the on disk (up-to-date)
  45. # version of index i1.
  46. #
  47. execsql { SELECT min(rowid) FROM t1 }
  48. } -test {
  49. faultsim_test_result {0 1}
  50. faultsim_integrity_check
  51. }
  52. finish_test