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. Particularly those that may occur
13 # when using contentless_delete=1 databases.
16 source [file join [file dirname [info script]] fts5_common.tcl]
17 source $testdir/malloc_common.tcl
18 set testprefix fts5faultF
20 # If SQLITE_ENABLE_FTS5 is not defined, omit this file.
26 faultsim_save_and_close
27 do_faultsim_test 1 -prep {
28 faultsim_restore_and_reopen
31 CREATE VIRTUAL TABLE t1 USING fts5(x, y, content=, contentless_delete=1)
34 faultsim_test_result {0 {}} {1 {vtable constructor failed: t1}}
39 CREATE VIRTUAL TABLE t1 USING fts5(doc, content=, contentless_delete=1);
41 INSERT INTO t1(rowid, doc) VALUES(1, 'a b c d');
42 INSERT INTO t1(rowid, doc) VALUES(2, 'a b c d');
43 INSERT INTO t1(rowid, doc) VALUES(3, 'a b c d');
44 INSERT INTO t1(rowid, doc) VALUES(4, 'a b c d');
46 DELETE FROM t1 WHERE rowid IN (2, 4);
49 do_faultsim_test 2 -prep {
51 execsql { SELECT rowid FROM t1 }
54 SELECT rowid FROM t1('b c');
57 faultsim_test_result {0 {1 3}}
60 #-------------------------------------------------------------------------
63 CREATE VIRTUAL TABLE t1 USING fts5(doc, content=, contentless_delete=1);
65 INSERT INTO t1(rowid, doc) VALUES(1, 'a b c d');
66 INSERT INTO t1(rowid, doc) VALUES(2, 'a b c d');
67 INSERT INTO t1(rowid, doc) VALUES(3, 'a b c d');
68 INSERT INTO t1(rowid, doc) VALUES(4, 'a b c d');
72 faultsim_save_and_close
73 do_faultsim_test 3 -prep {
74 faultsim_restore_and_reopen
75 execsql { SELECT rowid FROM t1 }
78 INSERT INTO t1(rowid, doc) VALUES(5, 'a b c d');
81 faultsim_test_result {0 {}}
84 #-------------------------------------------------------------------------
87 CREATE VIRTUAL TABLE t1 USING fts5(doc, content=, contentless_delete=1);
88 INSERT INTO t1(t1, rank) VALUES('pgsz', 64);
90 SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<1000
92 INSERT INTO t1(rowid, doc) SELECT i, 'a b c d' FROM s;
95 do_execsql_test 4.1 { DELETE FROM t1 WHERE rowid <= 25 }
97 faultsim_save_and_close
98 do_faultsim_test 4 -faults oom-t* -prep {
99 faultsim_restore_and_reopen
100 execsql { SELECT rowid FROM t1 }
103 DELETE FROM t1 WHERE rowid < 100
106 faultsim_test_result {0 {}}