3 # The author disclaims copyright to this source code. In place of
4 # a legal notice, here is a blessing:
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.
10 #***********************************************************************
12 # This file contains fault injection tests designed to test the btree.c
16 set testdir [file dirname $argv0]
17 source $testdir/tester.tcl
18 source $testdir/malloc_common.tcl
19 set testprefix btreefault
21 # This test will not work with an in-memory journal, as the database will
22 # become corrupt if an error is injected into a transaction after it starts
23 # writing data out to the db file.
24 if {[permutation]=="inmemory_journal"} {
31 PRAGMA auto_vacuum = incremental;
32 PRAGMA journal_mode = DELETE;
33 CREATE TABLE t1(a PRIMARY KEY, b);
34 INSERT INTO t1 VALUES(randomblob(1000), randomblob(100));
35 INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;
36 INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;
37 INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;
38 INSERT INTO t1 SELECT randomblob(1000), randomblob(1000) FROM t1;
39 DELETE FROM t1 WHERE rowid%2;
41 faultsim_save_and_close
44 do_faultsim_test 1 -prep {
45 faultsim_restore_and_reopen
46 set ::STMT [sqlite3_prepare db "SELECT * FROM t1 ORDER BY a" -1 DUMMY]
50 execsql { PRAGMA incremental_vacuum = 10 }
52 sqlite3_finalize $::STMT
53 faultsim_test_result {0 {}}
54 faultsim_integrity_check
57 #-------------------------------------------------------------------------
58 # dbsqlfuzz crash-6ef3cd3b18ccc5de86120950a0498641acd90a33.txt
63 CREATE TABLE t1(i INTEGER PRIMARY KEY, a, b);
64 CREATE INDEX i1 ON t1(b);
65 CREATE TABLE t2(x, y);
69 INSERT INTO t1 VALUES(25, 25, 25);
70 INSERT INTO t2 VALUES(25, 'a'), (25, 'b'), (25, 'c');
77 SELECT x, y FROM t1 CROSS JOIN t2 WHERE t2.x=t1.i AND +t1.i=25 ORDER BY b
81 db eval { DELETE FROM t1 WHERE i=25 }
87 do_faultsim_test 2 -faults oom-t* -prep {
88 faultsim_restore_and_reopen
89 db eval {SELECT * FROM sqlite_master}
93 SELECT x, y FROM t1 CROSS JOIN t2 WHERE t2.x=t1.i AND +t1.i=25 ORDER BY b
97 db eval { DELETE FROM t1 WHERE i=25 }
102 faultsim_test_result {0 {25 a 25 b}}