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 is focused on OOM errors.
15 source [file join [file dirname [info script]] fts5_common.tcl]
16 source $testdir/malloc_common.tcl
17 set testprefix fts5fault8
19 # If SQLITE_ENABLE_FTS3 is defined, omit this file.
25 foreach_detail_mode $testprefix {
27 fts5_aux_test_functions db
29 CREATE VIRTUAL TABLE t1 USING fts5(a, b, detail=%DETAIL%);
30 INSERT INTO t1 VALUES('a b c d', '1 2 3 4');
31 INSERT INTO t1 VALUES('a b a b', NULL);
32 INSERT INTO t1 VALUES(NULL, '1 2 1 2');
35 do_faultsim_test 1 -faults oom-* -body {
37 SELECT rowid, fts5_test_poslist(t1) FROM t1 WHERE t1 MATCH 'b OR 2'
40 faultsim_test_result {0 {1 {0.0.1 1.1.1} 2 {0.0.1 0.0.3} 3 {1.1.1 1.1.3}}} \
44 do_faultsim_test 2 -faults oom-* -body {
45 execsql { INSERT INTO t1(t1) VALUES('integrity-check') }
47 faultsim_test_result {0 {}} {1 SQLITE_NOMEM}
50 if {[detail_is_none]==0} {
51 do_faultsim_test 3 -faults oom-* -body {
52 execsql { SELECT rowid FROM t1('b:2') }
54 faultsim_test_result {0 {1 3}} {1 SQLITE_NOMEM}
58 } ;# foreach_detail_mode...
61 CREATE VIRTUAL TABLE x2 USING fts5(a);
62 INSERT INTO x2(x2, rank) VALUES('crisismerge', 2);
63 INSERT INTO x2(x2, rank) VALUES('pgsz', 32);
64 INSERT INTO x2 VALUES('a b c d');
65 INSERT INTO x2 VALUES('e f g h');
66 INSERT INTO x2 VALUES('i j k l');
67 INSERT INTO x2 VALUES('m n o p');
68 INSERT INTO x2 VALUES('q r s t');
69 INSERT INTO x2 VALUES('u v w x');
70 INSERT INTO x2 VALUES('y z a b');
72 faultsim_save_and_close
74 do_faultsim_test 4 -faults oom-* -prep {
75 faultsim_restore_and_reopen
77 execsql { INSERT INTO x2(x2) VALUES('optimize') }
79 faultsim_test_result {0 {}} {1 SQLITE_NOMEM}
82 set TMPDBERROR {1 {unable to open a temporary database file for storing temporary tables}}
84 do_faultsim_test 5 -faults oom-t* -prep {
85 faultsim_restore_and_reopen
86 execsql { PRAGMA temp_store = memory }
88 execsql { PRAGMA integrity_check }
90 if {[string match {*error code=7*} $testresult]==0} {
91 faultsim_test_result {0 ok} {1 SQLITE_NOMEM} $::TMPDBERROR