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 #***********************************************************************
13 set testdir [file dirname $argv0]
14 source $testdir/tester.tcl
15 set ::testprefix fts3fault2
17 # If SQLITE_ENABLE_FTS3 is not defined, omit this file.
18 ifcapable !fts3 { finish_test ; return }
22 CREATE VIRTUAL TABLE t1 USING fts4(x);
23 INSERT INTO t1 VALUES('a b c');
24 INSERT INTO t1 VALUES('c d e');
25 CREATE VIRTUAL TABLE terms USING fts4aux(t1);
27 faultsim_save_and_close
30 do_faultsim_test 1.1 -prep {
31 faultsim_restore_and_reopen
32 db eval {SELECT * FROM sqlite_master}
34 execsql "CREATE VIRTUAL TABLE terms2 USING fts4aux(t1)"
36 faultsim_test_result {0 {}}
39 do_faultsim_test 1.2 -prep {
40 faultsim_restore_and_reopen
41 db eval {SELECT * FROM sqlite_master}
43 execsql "SELECT * FROM terms"
45 faultsim_test_result {0 {a * 1 1 a 0 1 1 b * 1 1 b 0 1 1 c * 2 2 c 0 2 2 d * 1 1 d 0 1 1 e * 1 1 e 0 1 1}}
48 do_faultsim_test 1.3 -prep {
49 faultsim_restore_and_reopen
50 db eval {SELECT * FROM sqlite_master}
52 execsql "SELECT * FROM terms WHERE term>'a' AND TERM < 'd'"
54 faultsim_test_result {0 {b * 1 1 b 0 1 1 c * 2 2 c 0 2 2}}
57 do_faultsim_test 1.4 -prep {
58 faultsim_restore_and_reopen
59 db eval {SELECT * FROM sqlite_master}
61 execsql "SELECT * FROM terms WHERE term='c'"
63 faultsim_test_result {0 {c * 2 2 c 0 2 2}}
67 faultsim_delete_and_reopen
69 CREATE VIRTUAL TABLE tx USING fts4(a, b);
70 INSERT INTO tx VALUES('a b c', 'x y z');
71 CREATE VIRTUAL TABLE terms2 USING fts4aux(tx);
73 faultsim_save_and_close
76 do_faultsim_test 2.1 -prep {
77 faultsim_restore_and_reopen
78 db eval {SELECT * FROM sqlite_master}
80 execsql "SELECT * FROM terms2"
82 faultsim_test_result {0 {a * 1 1 a 0 1 1 b * 1 1 b 0 1 1 c * 1 1 c 0 1 1 x * 1 1 x 1 1 1 y * 1 1 y 1 1 1 z * 1 1 z 1 1 1}}
85 do_faultsim_test 3.0 -faults oom* -prep {
86 faultsim_delete_and_reopen
87 db eval { CREATE TABLE 'xx yy'(a, b); }
90 CREATE VIRTUAL TABLE tt USING fts4(content="xx yy");
93 faultsim_test_result {0 {}}
96 do_faultsim_test 3.1 -faults oom* -prep {
97 faultsim_delete_and_reopen
102 CREATE VIRTUAL TABLE tt USING fts4(compress=zip, uncompress=unzip);
105 faultsim_test_result {0 {}}
109 faultsim_delete_and_reopen
111 CREATE VIRTUAL TABLE ft USING fts4(a, b);
112 INSERT INTO ft VALUES('U U T C O', 'F N D E S');
113 INSERT INTO ft VALUES('P H X G B', 'I D M R U');
114 INSERT INTO ft VALUES('P P X D M', 'Y V N T C');
115 INSERT INTO ft VALUES('Z L Q O W', 'D F U N Q');
116 INSERT INTO ft VALUES('A J D U P', 'C H M Q E');
117 INSERT INTO ft VALUES('P S A O H', 'S Z C W D');
118 INSERT INTO ft VALUES('T B N L W', 'C A K T I');
119 INSERT INTO ft VALUES('K E Z L O', 'L L Y C E');
120 INSERT INTO ft VALUES('C R E S V', 'Q V F W P');
121 INSERT INTO ft VALUES('S K H G W', 'R W Q F G');
123 faultsim_save_and_close
125 do_faultsim_test 4.1 -prep {
126 faultsim_restore_and_reopen
127 db eval {SELECT * FROM sqlite_master}
129 execsql { INSERT INTO ft(ft) VALUES('rebuild') }
131 faultsim_test_result {0 {}}
134 ifcapable fts3_unicode {
136 faultsim_delete_and_reopen
138 CREATE VIRTUAL TABLE ft USING fts4(a, tokenize=unicode61);
140 faultsim_save_and_close
143 do_faultsim_test 5.1 -faults oom* -prep {
144 faultsim_restore_and_reopen
145 db eval {SELECT * FROM sqlite_master}
147 execsql { INSERT INTO ft VALUES('the quick brown fox'); }
148 execsql { INSERT INTO ft VALUES(
149 'theunusuallylongtokenthatjustdragsonandonandonandthendragsonsomemoreeof'
152 execsql { SELECT docid FROM ft WHERE ft MATCH 'th*' }
154 faultsim_test_result {0 {1 2}}