pagerfault3.test 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # 2011 January 28
  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. #
  12. set testdir [file dirname $argv0]
  13. source $testdir/tester.tcl
  14. source $testdir/lock_common.tcl
  15. source $testdir/malloc_common.tcl
  16. if {[permutation] == "inmemory_journal"} {
  17. finish_test
  18. return
  19. }
  20. # Create a database with page-size 2048 bytes that uses 2 pages. Populate
  21. # it so that if the page-size is changed to 1024 bytes and the db vacuumed,
  22. # the new db size is 3 pages.
  23. #
  24. do_test pagerfault3-pre1 {
  25. execsql {
  26. PRAGMA auto_vacuum = 0;
  27. PRAGMA page_size = 2048;
  28. CREATE TABLE t1(x);
  29. INSERT INTO t1 VALUES(randomblob(1200));
  30. PRAGMA page_count;
  31. }
  32. } {2}
  33. do_test pagerfault3-pre2 {
  34. faultsim_save_and_close
  35. faultsim_restore_and_reopen
  36. execsql {
  37. PRAGMA page_size = 1024;
  38. VACUUM;
  39. PRAGMA page_count;
  40. }
  41. } {3}
  42. # Now do the page-size change and VACUUM with IO error injection. When
  43. # an IO error is injected into the final xSync() of the commit, the pager
  44. # will have to extend the db file from 3072 to 4096 byts when rolling
  45. # back the hot-journal file. This is a special case in pager_truncate().
  46. #
  47. do_faultsim_test pagerfault3-1 -faults ioerr-transient -prep {
  48. faultsim_restore_and_reopen
  49. } -body {
  50. execsql {
  51. PRAGMA page_size = 1024;
  52. VACUUM;
  53. }
  54. } -test {
  55. faultsim_test_result {0 {}}
  56. faultsim_integrity_check
  57. }
  58. finish_test