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