OLD | NEW |
1 # 2011 May 04 | 1 # 2011 May 04 |
2 # | 2 # |
3 # The author disclaims copyright to this source code. In place of | 3 # The author disclaims copyright to this source code. In place of |
4 # a legal notice, here is a blessing: | 4 # a legal notice, here is a blessing: |
5 # | 5 # |
6 # May you do good and not evil. | 6 # May you do good and not evil. |
7 # May you find forgiveness for yourself and forgive others. | 7 # May you find forgiveness for yourself and forgive others. |
8 # May you share freely, never taking more than you give. | 8 # May you share freely, never taking more than you give. |
9 # | 9 # |
10 #************************************************************************* | 10 #************************************************************************* |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 | 202 |
203 #------------------------------------------------------------------------- | 203 #------------------------------------------------------------------------- |
204 # Syntax tests. | 204 # Syntax tests. |
205 # | 205 # |
206 do_catchsql_test 5.1 { | 206 do_catchsql_test 5.1 { |
207 CREATE VIRTUAL TABLE t4 USING fts4(prefix="abc"); | 207 CREATE VIRTUAL TABLE t4 USING fts4(prefix="abc"); |
208 } {1 {error parsing prefix parameter: abc}} | 208 } {1 {error parsing prefix parameter: abc}} |
209 do_catchsql_test 5.2 { | 209 do_catchsql_test 5.2 { |
210 CREATE VIRTUAL TABLE t4 USING fts4(prefix=""); | 210 CREATE VIRTUAL TABLE t4 USING fts4(prefix=""); |
211 } {0 {}} | 211 } {0 {}} |
| 212 do_catchsql_test 5.3 { |
| 213 CREATE VIRTUAL TABLE t5 USING fts4(prefix="-1"); |
| 214 } {1 {error parsing prefix parameter: -1}} |
| 215 |
| 216 #------------------------------------------------------------------------- |
| 217 # Prefix indexes of size 0 are ignored. Demonstrate this by showing that |
| 218 # adding prefix=0 does not change the contents of the %_segdir table. |
| 219 # |
| 220 reset_db |
| 221 do_execsql_test 6.1.1 { |
| 222 CREATE VIRTUAL TABLE t1 USING fts4(prefix=0); |
| 223 CREATE VIRTUAL TABLE t2 USING fts4; |
| 224 INSERT INTO t1 VALUES('Twas Mulga Bill, from Eaglehawk, '); |
| 225 INSERT INTO t2 VALUES('Twas Mulga Bill, from Eaglehawk, '); |
| 226 } {} |
| 227 do_execsql_test 6.1.2 { |
| 228 SELECT md5sum(quote(root)) FROM t1_segdir; |
| 229 } [db eval {SELECT md5sum(quote(root)) FROM t2_segdir}] |
| 230 |
| 231 reset_db |
| 232 do_execsql_test 6.2.1 { |
| 233 CREATE VIRTUAL TABLE t1 USING fts4(prefix="1,0,2"); |
| 234 CREATE VIRTUAL TABLE t2 USING fts4(prefix="1,2"); |
| 235 INSERT INTO t1 VALUES('that caught the cycling craze;'); |
| 236 INSERT INTO t2 VALUES('that caught the cycling craze;'); |
| 237 } {} |
| 238 do_execsql_test 6.2.2 { |
| 239 SELECT md5sum(quote(root)) FROM t1_segdir; |
| 240 } [db eval {SELECT md5sum(quote(root)) FROM t2_segdir}] |
| 241 |
| 242 reset_db |
| 243 do_execsql_test 6.3.1 { |
| 244 CREATE VIRTUAL TABLE t1 USING fts4(prefix="1,3,2"); |
| 245 CREATE VIRTUAL TABLE t2 USING fts4(prefix="1,2"); |
| 246 INSERT INTO t1 VALUES('He turned away the good old horse'); |
| 247 INSERT INTO t2 VALUES('He turned away the good old horse'); |
| 248 } {} |
| 249 do_test 6.3.2 { |
| 250 set one [db eval {SELECT md5sum(quote(root)) FROM t1_segdir}] |
| 251 set two [db eval {SELECT md5sum(quote(root)) FROM t2_segdir}] |
| 252 expr {$one == $two} |
| 253 } 0 |
| 254 |
| 255 reset_db |
| 256 do_execsql_test 6.4.1 { |
| 257 CREATE VIRTUAL TABLE t1 USING fts4(prefix="1,600,2"); |
| 258 CREATE VIRTUAL TABLE t2 USING fts4(prefix="1,2"); |
| 259 INSERT INTO t1 VALUES('that served him many days;'); |
| 260 INSERT INTO t2 VALUES('that served him many days;'); |
| 261 } {} |
| 262 do_execsql_test 6.4.2 { |
| 263 SELECT md5sum(quote(root)) FROM t1_segdir; |
| 264 } [db eval {SELECT md5sum(quote(root)) FROM t2_segdir}] |
| 265 |
| 266 reset_db |
| 267 do_execsql_test 6.5.1 { |
| 268 CREATE VIRTUAL TABLE t1 USING fts4(prefix="2147483647,2147483648,2147483649"); |
| 269 CREATE VIRTUAL TABLE t2 USING fts4(prefix=); |
| 270 INSERT INTO t1 VALUES('He dressed himself in cycling clothes'); |
| 271 INSERT INTO t2 VALUES('He dressed himself in cycling clothes'); |
| 272 } {} |
| 273 do_execsql_test 6.5.2 { |
| 274 SELECT md5sum(quote(root)) FROM t1_segdir; |
| 275 } [db eval {SELECT md5sum(quote(root)) FROM t2_segdir}] |
| 276 |
| 277 |
| 278 do_execsql_test 7.0 { |
| 279 CREATE VIRTUAL TABLE t6 USING fts4(x,order=DESC); |
| 280 INSERT INTO t6(docid, x) VALUES(-1,'a b'); |
| 281 INSERT INTO t6(docid, x) VALUES(1, 'b'); |
| 282 } |
| 283 do_execsql_test 7.1 { |
| 284 SELECT docid FROM t6 WHERE t6 MATCH '"a* b"'; |
| 285 } {-1} |
| 286 do_execsql_test 7.2 { |
| 287 SELECT docid FROM t6 WHERE t6 MATCH 'a*'; |
| 288 } {-1} |
| 289 do_execsql_test 7.3 { |
| 290 SELECT docid FROM t6 WHERE t6 MATCH 'a* b'; |
| 291 } {-1} |
| 292 |
| 293 |
212 | 294 |
213 finish_test | 295 finish_test |
OLD | NEW |