blob: 7f6c995efd603f6dcc76a83df701cf1b3907bfc2 [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
danb3f43512010-07-03 16:37:45 +000025if {[permutation] == "inmemory_journal"} {
26 finish_test
27 return
28}
29
danc396d4a2010-07-02 11:27:43 +000030sqlite3_memdebug_vfs_oom_test 0
31
dan273f3f02010-06-26 15:42:33 +000032set a_string_counter 1
33proc a_string {n} {
34 global a_string_counter
35 incr a_string_counter
36 string range [string repeat "${a_string_counter}." $n] 1 $n
37}
38db func a_string a_string
39
dan273f3f02010-06-26 15:42:33 +000040do_test pagerfault2-1-pre1 {
41 faultsim_delete_and_reopen
42 db func a_string a_string
43 execsql {
danf43d7fc2010-07-03 10:00:00 +000044 PRAGMA auto_vacuum = 0;
dan273f3f02010-06-26 15:42:33 +000045 PRAGMA journal_mode = DELETE;
danc396d4a2010-07-02 11:27:43 +000046 PRAGMA page_size = 1024;
dan273f3f02010-06-26 15:42:33 +000047 CREATE TABLE t1(a, b);
48 INSERT INTO t1 VALUES(a_string(401), a_string(402));
49 }
danc396d4a2010-07-02 11:27:43 +000050 for {set ii 0} {$ii < 13} {incr ii} {
dan273f3f02010-06-26 15:42:33 +000051 execsql { INSERT INTO t1 SELECT a_string(401), a_string(402) FROM t1 }
52 }
53 faultsim_save_and_close
danc396d4a2010-07-02 11:27:43 +000054 file size test.db
55} [expr 1024 * 8268]
56
57do_faultsim_test pagerfault2-1 -faults oom-transient -prep {
dan273f3f02010-06-26 15:42:33 +000058 faultsim_restore_and_reopen
danc396d4a2010-07-02 11:27:43 +000059 sqlite3_db_config_lookaside db 0 256 4096
dan273f3f02010-06-26 15:42:33 +000060 execsql {
61 BEGIN;
danc396d4a2010-07-02 11:27:43 +000062 SELECT * FROM t1;
dan273f3f02010-06-26 15:42:33 +000063 INSERT INTO t1 VALUES(5, 6);
64 SAVEPOINT abc;
danc396d4a2010-07-02 11:27:43 +000065 UPDATE t1 SET a = a||'x' WHERE rowid<3700;
dan273f3f02010-06-26 15:42:33 +000066 }
67} -body {
danc396d4a2010-07-02 11:27:43 +000068 execsql { UPDATE t1 SET a = a||'x' WHERE rowid>=3700 AND rowid<=4200 }
dan273f3f02010-06-26 15:42:33 +000069 execsql { ROLLBACK TO abc }
70} -test {
71 faultsim_test_result {0 {}}
dan273f3f02010-06-26 15:42:33 +000072}
73
danc396d4a2010-07-02 11:27:43 +000074do_test pagerfault2-2-pre1 {
75 faultsim_restore_and_reopen
76 execsql { DELETE FROM t1 }
77 faultsim_save_and_close
78} {}
79
80do_faultsim_test pagerfault2-2 -faults oom-transient -prep {
81 faultsim_restore_and_reopen
82 sqlite3_db_config_lookaside db 0 256 4096
83 db func a_string a_string
84
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 1
dan273f3f02010-06-26 15:42:33 +000098finish_test