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 source [file join [file dirname [info script]] fts5_common.tcl]
14 set testprefix fts5simple2
16 # If SQLITE_ENABLE_FTS5 is defined, omit this file.
23 CREATE VIRTUAL TABLE t1 USING fts5(a, detail=none);
24 INSERT INTO t1 VALUES('a b c');
27 SELECT rowid FROM t1('c a b')
30 #-------------------------------------------------------------------------
34 CREATE VIRTUAL TABLE t1 USING fts5(a, detail=none);
36 INSERT INTO t1 VALUES('b c d');
37 INSERT INTO t1 VALUES('b c d');
41 SELECT rowid FROM t1('b c d')
44 #-------------------------------------------------------------------------
48 CREATE VIRTUAL TABLE t1 USING fts5(a, detail=none);
50 INSERT INTO t1 VALUES('b c d');
51 INSERT INTO t1 VALUES('b c d');
54 SELECT rowid FROM t1('b c d'); COMMIT;
57 #-------------------------------------------------------------------------
61 CREATE VIRTUAL TABLE t1 USING fts5(a, detail=none);
63 INSERT INTO t1 VALUES('a1 b1 c1');
64 INSERT INTO t1 VALUES('a2 b2 c2');
65 INSERT INTO t1 VALUES('a3 b3 c3');
69 SELECT rowid FROM t1('b*');
73 #-------------------------------------------------------------------------
77 CREATE VIRTUAL TABLE t1 USING fts5(a, detail=none);
79 INSERT INTO t1 VALUES('a1 b1 c1');
80 INSERT INTO t1 VALUES('a2 b2 c2');
81 INSERT INTO t1 VALUES('a1 b1 c1');
84 do_execsql_test 5.1 { SELECT rowid FROM t1('b*') } {1 2 3}
86 #-------------------------------------------------------------------------
90 CREATE VIRTUAL TABLE t1 USING fts5(a, detail=full);
92 INSERT INTO t1 VALUES('a1 b1 c1');
93 INSERT INTO t1 VALUES('a1 b1 c1');
94 INSERT INTO t1 VALUES('a1 b1 c1');
98 do_execsql_test 6.1 { SELECT rowid FROM t1('a1') ORDER BY rowid DESC } {3 2 1}
99 do_execsql_test 6.2 { SELECT rowid FROM t1('b1') ORDER BY rowid DESC } {3 2 1}
100 do_execsql_test 6.3 { SELECT rowid FROM t1('c1') ORDER BY rowid DESC } {3 2 1}
102 #-------------------------------------------------------------------------
105 do_execsql_test 7.0 {
106 CREATE VIRTUAL TABLE t1 USING fts5(a, detail=none);
108 INSERT INTO t1 VALUES('a1 b1');
109 INSERT INTO t1 VALUES('a1 b2');
112 do_execsql_test 7.1 { SELECT rowid FROM t1('b*') ORDER BY rowid DESC } {2 1}
113 do_execsql_test 7.2 { SELECT rowid FROM t1('a1') ORDER BY rowid DESC } {2 1}
115 #-------------------------------------------------------------------------
118 do_execsql_test 8.0 {
119 CREATE VIRTUAL TABLE t1 USING fts5(a, detail=none);
120 INSERT INTO t1 VALUES('a1 b1 c1');
121 INSERT INTO t1 VALUES('a2 b2 c2');
122 INSERT INTO t1 VALUES('a1 b1 c1');
124 do_execsql_test 8.0.1 { SELECT rowid FROM t1('b*') } {1 2 3}
125 do_execsql_test 8.0.2 { SELECT rowid FROM t1('a1') } {1 3}
126 do_execsql_test 8.0.3 { SELECT rowid FROM t1('c2') } {2}
128 do_execsql_test 8.0.4 { SELECT rowid FROM t1('b*') ORDER BY rowid DESC } {3 2 1}
129 do_execsql_test 8.0.5 { SELECT rowid FROM t1('a1') ORDER BY rowid DESC } {3 1}
130 do_execsql_test 8.0.8 { SELECT rowid FROM t1('c2') ORDER BY rowid DESC } {2}
132 do_execsql_test 8.1.0 { INSERT INTO t1(t1) VALUES('optimize') }
134 do_execsql_test 8.1.1 { SELECT rowid FROM t1('b*') } {1 2 3}
135 do_execsql_test 8.1.2 { SELECT rowid FROM t1('a1') } {1 3}
136 do_execsql_test 8.1.3 { SELECT rowid FROM t1('c2') } {2}
138 do_execsql_test 8.2.1 { SELECT rowid FROM t1('b*') ORDER BY rowid DESC} {3 2 1}
139 do_execsql_test 8.2.2 { SELECT rowid FROM t1('a1') ORDER BY rowid DESC} {3 1}
140 do_execsql_test 8.2.3 { SELECT rowid FROM t1('c2') ORDER BY rowid DESC} {2}
142 #--------------------------------------------------------------------------
145 do_execsql_test 9.0.0 {
146 CREATE VIRTUAL TABLE t1 USING fts5(a, detail=none);
147 INSERT INTO t1 VALUES('a1 b1 c1');
148 INSERT INTO t1 VALUES('a2 b2 c2');
149 INSERT INTO t1 VALUES('a1 b1 c1');
151 do_execsql_test 9.0.1 {
152 INSERT INTO t1(t1) VALUES('integrity-check');
156 do_execsql_test 9.1.0 {
157 CREATE VIRTUAL TABLE t1 USING fts5(a, b, detail=none);
158 INSERT INTO t1 VALUES('a1 b1 c1', 'x y z');
159 INSERT INTO t1 VALUES('a2 b2 c2', '1 2 3');
160 INSERT INTO t1 VALUES('a1 b1 c1', 'x 2 z');
162 do_execsql_test 9.2.1 {
163 INSERT INTO t1(t1) VALUES('integrity-check');
166 #--------------------------------------------------------------------------
169 do_execsql_test 10.0 {
170 CREATE VIRTUAL TABLE t1 USING fts5(a, detail=none);
171 INSERT INTO t1 VALUES('b1');
172 INSERT INTO t1 VALUES('b1');
173 DELETE FROM t1 WHERE rowid=1;
176 do_execsql_test 10.1 {
177 SELECT rowid FROM t1('b1');
180 do_execsql_test 10.2 {
181 SELECT rowid FROM t1('b1') ORDER BY rowid DESC;
184 do_execsql_test 10.3 {
185 INSERT INTO t1(t1) VALUES('integrity-check');
188 #--------------------------------------------------------------------------
191 do_execsql_test 11.1 {
192 CREATE VIRTUAL TABLE t1 USING fts5(x, y, detail=none);
193 INSERT INTO t1(t1, rank) VALUES('pgsz', 32);
195 SELECT NULL, 'xyz' UNION ALL SELECT NULL, 'xyz' FROM d
197 INSERT INTO t1 SELECT * FROM d LIMIT 23;
200 #db eval { SELECT rowid AS r, quote(block) AS b FROM t1_data } { puts "$r: $b" }
201 do_execsql_test 11.2 {
202 SELECT rowid FROM t1;
203 } {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23}
205 do_execsql_test 11.3 {
206 SELECT rowid FROM t1('xyz');
207 } {1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23}
209 do_execsql_test 11.4 {
210 INSERT INTO t1(t1) VALUES('integrity-check');
213 #-------------------------------------------------------------------------
216 do_execsql_test 12.0 {
217 CREATE VIRTUAL TABLE yy USING fts5(x, detail=none);
218 INSERT INTO yy VALUES('in if');
219 INSERT INTO yy VALUES('if');
222 do_execsql_test 12.1 {
223 SELECT rowid FROM yy('i*');
226 #-------------------------------------------------------------------------
229 do_execsql_test 13.0 {
230 CREATE VIRTUAL TABLE t1 USING fts5(a, prefix=1, detail=none);
250 do_execsql_test 13.1.$rowid {
251 INSERT INTO t1(rowid, a) VALUES($rowid, $a);
255 #-------------------------------------------------------------------------
258 fts5_aux_test_functions db
259 do_execsql_test 14.0 {
260 CREATE VIRTUAL TABLE t1 USING fts5(a, detail=none);
261 INSERT INTO t1 VALUES('a b c d');
264 do_execsql_test 14.1 {
265 SELECT fts5_test_poslist(t1) FROM t1('b') ORDER BY rank;
268 #-------------------------------------------------------------------------
271 do_execsql_test 15.1 {
272 CREATE VIRTUAL TABLE t1 USING fts5(x, detail=none);
274 INSERT INTO t1(rowid, x) VALUES(1, 'sqlite');
275 INSERT INTO t1(rowid, x) VALUES(2, 'sqlite');
280 execsql { INSERT INTO t1(t1) VALUES('integrity-check') }
284 execsql { DELETE FROM t1 }
287 do_execsql_test 15.3.1 {
288 SELECT rowid FROM t1('sqlite');
291 do_execsql_test 15.3.2 {
292 SELECT rowid FROM t1('sqlite') ORDER BY rowid DESC;
296 execsql { INSERT INTO t1(t1) VALUES('integrity-check') }
299 #-------------------------------------------------------------------------
302 do_execsql_test 16.0 {
303 CREATE VIRTUAL TABLE t2 USING fts5(x, detail=none);
305 INSERT INTO t2(rowid, x) VALUES(1, 'a b c');
306 INSERT INTO t2(rowid, x) VALUES(456, 'a b c');
307 INSERT INTO t2(rowid, x) VALUES(1000, 'a b c');
312 do_execsql_test 16.1 {
313 INSERT INTO t2(t2) VALUES('integrity-check');
316 do_execsql_test 16.2 {
317 SELECT rowid FROM t2('b') ORDER BY rowid DESC
321 #-------------------------------------------------------------------------
324 do_execsql_test 16.0 {
325 CREATE VIRTUAL TABLE t2 USING fts5(x, detail=none);
327 INSERT INTO t2(rowid, x) VALUES(1, 'a b c');
328 INSERT INTO t2(rowid, x) VALUES(456, 'a b c');
329 INSERT INTO t2(rowid, x) VALUES(1000, 'a b c');
335 #db eval {SELECT rowid, fts5_decode_none(rowid, block) aS r FROM t2_data} {puts $r}