blob: 931b89b70e3855b24fd3951a5a444eec0273cd5c [file] [log] [blame]
dan273f3f02010-06-26 15:42:33 +00001# 2010 June 15
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# The tests in this file test the pager modules response to various
13# fault conditions (OOM, IO error, disk full etc.). They are similar
14# 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.tcl
22source $testdir/lock_common.tcl
23source $testdir/malloc_common.tcl
24
danc396d4a2010-07-02 11:27:43 +000025sqlite3_memdebug_vfs_oom_test 0
26
dan273f3f02010-06-26 15:42:33 +000027set a_string_counter 1
28proc a_string {n} {
29 global a_string_counter
30 incr a_string_counter
31 string range [string repeat "${a_string_counter}." $n] 1 $n
32}
33db func a_string a_string
34
dan273f3f02010-06-26 15:42:33 +000035do_test pagerfault2-1-pre1 {
36 faultsim_delete_and_reopen
37 db func a_string a_string
38 execsql {
danf43d7fc2010-07-03 10:00:00 +000039 PRAGMA auto_vacuum = 0;
dan273f3f02010-06-26 15:42:33 +000040 PRAGMA journal_mode = DELETE;
danc396d4a2010-07-02 11:27:43 +000041 PRAGMA page_size = 1024;
dan273f3f02010-06-26 15:42:33 +000042 CREATE TABLE t1(a, b);
43 INSERT INTO t1 VALUES(a_string(401), a_string(402));
44 }
danc396d4a2010-07-02 11:27:43 +000045 for {set ii 0} {$ii < 13} {incr ii} {
dan273f3f02010-06-26 15:42:33 +000046 execsql { INSERT INTO t1 SELECT a_string(401), a_string(402) FROM t1 }
47 }
48 faultsim_save_and_close
danc396d4a2010-07-02 11:27:43 +000049 file size test.db
50} [expr 1024 * 8268]
51
52do_faultsim_test pagerfault2-1 -faults oom-transient -prep {
dan273f3f02010-06-26 15:42:33 +000053 faultsim_restore_and_reopen
danc396d4a2010-07-02 11:27:43 +000054 sqlite3_db_config_lookaside db 0 256 4096
dan273f3f02010-06-26 15:42:33 +000055 execsql {
56 BEGIN;
danc396d4a2010-07-02 11:27:43 +000057 SELECT * FROM t1;
dan273f3f02010-06-26 15:42:33 +000058 INSERT INTO t1 VALUES(5, 6);
59 SAVEPOINT abc;
danc396d4a2010-07-02 11:27:43 +000060 UPDATE t1 SET a = a||'x' WHERE rowid<3700;
dan273f3f02010-06-26 15:42:33 +000061 }
62} -body {
danc396d4a2010-07-02 11:27:43 +000063 execsql { UPDATE t1 SET a = a||'x' WHERE rowid>=3700 AND rowid<=4200 }
dan273f3f02010-06-26 15:42:33 +000064 execsql { ROLLBACK TO abc }
65} -test {
66 faultsim_test_result {0 {}}
dan273f3f02010-06-26 15:42:33 +000067}
68
danc396d4a2010-07-02 11:27:43 +000069do_test pagerfault2-2-pre1 {
70 faultsim_restore_and_reopen
71 execsql { DELETE FROM t1 }
72 faultsim_save_and_close
73} {}
74
75do_faultsim_test pagerfault2-2 -faults oom-transient -prep {
76 faultsim_restore_and_reopen
77 sqlite3_db_config_lookaside db 0 256 4096
78 db func a_string a_string
79
80 execsql {
81 PRAGMA cache_size = 20;
82 BEGIN;
83 INSERT INTO t1 VALUES(a_string(401), a_string(402));
84 SAVEPOINT abc;
85 }
86} -body {
87 execsql { INSERT INTO t1 VALUES (a_string(2000000), a_string(2500000)) }
88} -test {
89 faultsim_test_result {0 {}}
90}
91
92sqlite3_memdebug_vfs_oom_test 1
dan273f3f02010-06-26 15:42:33 +000093finish_test
danc396d4a2010-07-02 11:27:43 +000094