CoolFace
Modelpublic

AryaWu/sqlite

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
pagerfault2.test99 linesDownload Raw Back to test
1# 2010 June 152#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#12# The tests in this file test the pager modules response to various13# fault conditions (OOM, IO error, disk full etc.). They are similar14# to those in file pagerfault1.test. 15#16# More specifically, the tests in this file are those deemed too slow to 17# run as part of pagerfault1.test.18#19 20set testdir [file dirname $argv0]21source $testdir/tester.tcl22source $testdir/lock_common.tcl23source $testdir/malloc_common.tcl24 25if {[permutation] == "inmemory_journal"} {26  finish_test27  return28}29 30sqlite3_memdebug_vfs_oom_test 031 32set a_string_counter 133proc a_string {n} {34  global a_string_counter35  incr a_string_counter36  string range [string repeat "${a_string_counter}." $n] 1 $n37}38db func a_string a_string39 40do_test pagerfault2-1-pre1 {41  faultsim_delete_and_reopen42  db func a_string a_string43  execsql {44    PRAGMA auto_vacuum = 0;45    PRAGMA journal_mode = DELETE;46    PRAGMA page_size = 1024;47    CREATE TABLE t1(a, b);48    INSERT INTO t1 VALUES(a_string(401), a_string(402));49  }50  for {set ii 0} {$ii < 13} {incr ii} {51    execsql { INSERT INTO t1 SELECT a_string(401), a_string(402) FROM t1 }52  }53  faultsim_save_and_close54  file size test.db55} [expr 1024 * 8268]56 57do_faultsim_test pagerfault2-1 -faults oom-transient -prep {58  faultsim_restore_and_reopen59  sqlite3_db_config_lookaside db 0 256 409660  execsql { 61    BEGIN;62      SELECT * FROM t1;63      INSERT INTO t1 VALUES(5, 6);64      SAVEPOINT abc;65        UPDATE t1 SET a = a||'x' WHERE rowid<3700;66  }67} -body {68  execsql { UPDATE t1 SET a = a||'x' WHERE rowid>=3700 AND rowid<=4200 }69  execsql { ROLLBACK TO abc }70} -test {71  faultsim_test_result {0 {}}72}73 74do_test pagerfault2-2-pre1 {75  faultsim_restore_and_reopen76  execsql { DELETE FROM t1 }77  faultsim_save_and_close78} {}79 80do_faultsim_test pagerfault2-2 -faults oom-transient -prep {81  faultsim_restore_and_reopen82  sqlite3_db_config_lookaside db 0 256 409683  db func a_string a_string84 85  execsql { 86    PRAGMA cache_size = 20;87    BEGIN;88      INSERT INTO t1 VALUES(a_string(401), a_string(402));89      SAVEPOINT abc;90  }91} -body {92  execsql { INSERT INTO t1 VALUES (a_string(2000000), a_string(2500000)) }93} -test {94  faultsim_test_result {0 {}}95}96 97sqlite3_memdebug_vfs_oom_test 198finish_test99