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 #*************************************************************************
11 # This file implements regression tests for SQLite library. The
12 # focus of this script is testing the FTS5 module.
15 source [file join [file dirname [info script]] fts5_common.tcl]
16 source $testdir/malloc_common.tcl
17 set testprefix fts5securefault
19 # If SQLITE_ENABLE_FTS5 is defined, omit this file.
23 CREATE VIRTUAL TABLE t1 USING fts5(ab);
24 INSERT INTO t1(rowid, ab) VALUES
25 (0, 'abc'), (1, 'abc'), (2, 'abc'), (3, 'abc'), (4, 'def');
27 faultsim_save_and_close
29 do_faultsim_test 1.1 -faults oom* -prep {
30 faultsim_restore_and_reopen
32 INSERT INTO t1(t1, rank) VALUES('secure-delete', 1);
35 execsql { DELETE FROM t1 WHERE rowid=2 }
37 faultsim_test_result {0 {}}
39 do_faultsim_test 1.2 -faults oom* -prep {
40 faultsim_restore_and_reopen
42 INSERT INTO t1(t1, rank) VALUES('secure-delete', 1);
45 execsql { DELETE FROM t1 WHERE rowid IN(0, 1, 2, 3, 4) }
47 faultsim_test_result {0 {}}
50 #-------------------------------------------------------------------------
53 set big [string repeat abcdefghij 5]
54 set big2 [string repeat klmnopqrst 5]
58 CREATE VIRTUAL TABLE t1 USING fts5(ab);
59 INSERT INTO t1(t1, rank) VALUES('pgsz', 64);
61 SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<4
63 INSERT INTO t1(rowid, ab) SELECT i, $doc FROM s;
65 faultsim_save_and_close
67 do_faultsim_test 2.1 -faults oom* -prep {
68 faultsim_restore_and_reopen
70 INSERT INTO t1(t1, rank) VALUES('secure-delete', 1);
73 execsql { DELETE FROM t1 WHERE rowid = 3 }
74 execsql { DELETE FROM t1 WHERE rowid = 4 }
76 faultsim_test_result {0 {}}
79 #-------------------------------------------------------------------------
82 set big [string repeat abcdefghij 5]
83 set big2 [string repeat klmnopqrst 5]
87 CREATE VIRTUAL TABLE t1 USING fts5(ab);
88 INSERT INTO t1(t1, rank) VALUES('pgsz', 64);
90 SELECT 1 UNION ALL SELECT i+1 FROM s WHERE i<25
92 INSERT INTO t1(rowid, ab) SELECT i, $doc FROM s;
94 INSERT INTO t1(t1, rank) VALUES('secure-delete', 1);
95 DELETE FROM t1 WHERE rowid BETWEEN 3 AND 23;
97 faultsim_save_and_close
99 do_faultsim_test 3.1 -faults oom* -prep {
100 faultsim_restore_and_reopen
102 INSERT INTO t1(t1, rank) VALUES('secure-delete', 1);
105 execsql { DELETE FROM t1 WHERE rowid = 24 }
106 execsql { DELETE FROM t1 WHERE rowid = 25 }
108 faultsim_test_result {0 {}}
111 #-------------------------------------------------------------------------
114 set doc [string repeat "tok " 400]
116 do_execsql_test 4.0 {
117 CREATE VIRTUAL TABLE t1 USING fts5(ab);
118 INSERT INTO t1(t1, rank) VALUES('pgsz', 64);
119 INSERT INTO t1(rowid, ab) VALUES(1, $doc), (2, $doc), (3, $doc);
121 faultsim_save_and_close
123 do_faultsim_test 4.1 -faults oom* -prep {
124 faultsim_restore_and_reopen
126 INSERT INTO t1(t1, rank) VALUES('secure-delete', 1);
129 execsql { DELETE FROM t1 WHERE rowid = 2 }
131 faultsim_test_result {0 {}}
134 #-------------------------------------------------------------------------
138 set doc1 [string repeat "abc " 10]
139 set doc2 [string repeat "def " 10]
143 CREATE VIRTUAL TABLE t1 USING fts5(ab);
144 INSERT INTO t1(t1, rank) VALUES('pgsz', 64);
147 for {set i 0} {$i < 50} {incr i} {
149 INSERT INTO t1(rowid, ab) VALUES($i, 'abcdefg');
153 INSERT INTO t1(rowid, ab) VALUES(105, 'def');
157 faultsim_save_and_close
159 do_faultsim_test 5.1 -faults oom* -prep {
160 faultsim_restore_and_reopen
162 INSERT INTO t1(t1, rank) VALUES('secure-delete', 1);
165 execsql { DELETE FROM t1 WHERE rowid = 105 }
167 faultsim_test_result {0 {}}
170 #-------------------------------------------------------------------------
175 CREATE VIRTUAL TABLE t1 USING fts5(ab);
176 INSERT INTO t1(t1, rank) VALUES('pgsz', 64);
178 INSERT INTO t1(rowid, ab) VALUES(1, 'abcdefg');
179 INSERT INTO t1(rowid, ab) VALUES(2, 'abcdefg');
180 INSERT INTO t1(rowid, ab) VALUES(3, 'abcdefg');
184 faultsim_save_and_close
186 do_faultsim_test 6.1 -faults oom* -prep {
187 faultsim_restore_and_reopen
189 INSERT INTO t1(t1, rank) VALUES('secure-delete', 1);
193 UPDATE t1 SET ab='abcdefg' WHERE rowid=2;
196 faultsim_test_result {0 {}}
199 #-------------------------------------------------------------------------
204 CREATE VIRTUAL TABLE t1 USING fts5(ab);
205 INSERT INTO t1(t1, rank) VALUES('pgsz', 32);
206 INSERT INTO t1(t1, rank) VALUES('secure-delete', 1);
209 faultsim_save_and_close
211 do_faultsim_test 7.1 -faults oom* -prep {
212 faultsim_restore_and_reopen
213 set big1 "[string repeat x 50] [string repeat y 50] [string repeat z 50]"
216 INSERT INTO t1 VALUES($big1);
221 faultsim_test_result {0 {}}