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 fts5fault7
19 # If SQLITE_ENABLE_FTS3 is defined, omit this file.
27 #-------------------------------------------------------------------------
28 # Test fault-injection on a query that uses xColumnSize() on columnsize=0
32 CREATE VIRTUAL TABLE t1 USING fts5(x, columnsize=0);
33 INSERT INTO t1 VALUES('a b c d e f g');
34 INSERT INTO t1 VALUES('a b c d');
35 INSERT INTO t1 VALUES('a b c d e f g h i j');
39 fts5_aux_test_functions db
40 do_faultsim_test 1 -faults oom* -body {
41 execsql { SELECT fts5_test_columnsize(t1) FROM t1 WHERE t1 MATCH 'b' }
43 faultsim_test_result {0 {7 4 10}} {1 SQLITE_NOMEM}
48 #-------------------------------------------------------------------------
49 # Test fault-injection when a segment is promoted.
52 CREATE VIRTUAL TABLE t2 USING fts5(a);
53 INSERT INTO t2(t2, rank) VALUES('automerge', 0);
54 INSERT INTO t2(t2, rank) VALUES('crisismerge', 4);
55 INSERT INTO t2(t2, rank) VALUES('pgsz', 40);
57 INSERT INTO t2 VALUES('a b c');
58 INSERT INTO t2 VALUES('d e f');
59 INSERT INTO t2 VALUES('f e d');
60 INSERT INTO t2 VALUES('c b a');
62 INSERT INTO t2 VALUES('a b c');
63 INSERT INTO t2 VALUES('d e f');
64 INSERT INTO t2 VALUES('f e d');
65 INSERT INTO t2 VALUES('c b a');
68 faultsim_save_and_close
69 do_faultsim_test 1 -faults oom-t* -prep {
70 faultsim_restore_and_reopen
73 INSERT INTO t2 VALUES('c d c g g f');
74 INSERT INTO t2 VALUES('c d g b f d');
75 INSERT INTO t2 VALUES('c c f d e d');
76 INSERT INTO t2 VALUES('e a f c e f');
77 INSERT INTO t2 VALUES('c g f b b d');
78 INSERT INTO t2 VALUES('d a g a b b');
79 INSERT INTO t2 VALUES('e f a b c e');
80 INSERT INTO t2 VALUES('e c a g c d');
81 INSERT INTO t2 VALUES('g b d d e b');
82 INSERT INTO t2 VALUES('e a d a e d');
87 faultsim_test_result {0 {}}
90 #-------------------------------------------------------------------------
91 # Test fault-injection when a segment is promoted.
95 CREATE VIRTUAL TABLE xy USING fts5(x);
96 INSERT INTO xy(rowid, x) VALUES(1, '1 2 3');
97 INSERT INTO xy(rowid, x) VALUES(2, '2 3 4');
98 INSERT INTO xy(rowid, x) VALUES(3, '3 4 5');
100 faultsim_save_and_close
102 do_faultsim_test 2.1 -faults oom-* -prep {
103 faultsim_restore_and_reopen
105 db eval { UPDATE OR REPLACE xy SET rowid=3 WHERE rowid = 2 }
107 faultsim_test_result {0 {}}
110 # Test fault-injection when an empty expression is parsed.
112 do_faultsim_test 2.2 -faults oom-* -body {
113 db eval { SELECT * FROM xy('""') }
115 faultsim_test_result {0 {}}