Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: third_party/sqlite/src/test/fts3matchinfo.test

Issue 901033002: Import SQLite 3.8.7.4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Chromium changes to support SQLite 3.8.7.4. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 # 2010 November 02 1 # 2010 November 02
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 #***********************************************************************
11 # This file implements regression tests for the FTS3 module. The focus 11 # This file implements regression tests for the FTS3 module. The focus
12 # of this file is tables created with the "matchinfo=fts3" option. 12 # of this file is tables created with the "matchinfo=fts3" option.
13 # 13 #
14 14
15 set testdir [file dirname $argv0] 15 set testdir [file dirname $argv0]
16 source $testdir/tester.tcl 16 source $testdir/tester.tcl
17 17
18 # If SQLITE_ENABLE_FTS3 is not defined, omit this file. 18 # If SQLITE_ENABLE_FTS3 is not defined, omit this file.
19 ifcapable !fts3 { finish_test ; return } 19 ifcapable !fts3 { finish_test ; return }
20 20
21 set testprefix fts3matchinfo 21 set testprefix fts3matchinfo
22 set sqlite_fts3_enable_parentheses 0
22 23
23 proc mit {blob} { 24 proc mit {blob} {
24 set scan(littleEndian) i* 25 set scan(littleEndian) i*
25 set scan(bigEndian) I* 26 set scan(bigEndian) I*
26 binary scan $blob $scan($::tcl_platform(byteOrder)) r 27 binary scan $blob $scan($::tcl_platform(byteOrder)) r
27 return $r 28 return $r
28 } 29 }
29 db func mit mit 30 db func mit mit
30 31
31 do_execsql_test 1.0 { 32 do_execsql_test 1.0 {
(...skipping 18 matching lines...) Expand all
50 } {{1 1 1 2 2} {1 1 1 2 2}} 51 } {{1 1 1 2 2} {1 1 1 2 2}}
51 52
52 # Test some syntax-error handling. 53 # Test some syntax-error handling.
53 # 54 #
54 do_catchsql_test 2.0 { 55 do_catchsql_test 2.0 {
55 CREATE VIRTUAL TABLE x1 USING fts4(matchinfo=fs3); 56 CREATE VIRTUAL TABLE x1 USING fts4(matchinfo=fs3);
56 } {1 {unrecognized matchinfo: fs3}} 57 } {1 {unrecognized matchinfo: fs3}}
57 do_catchsql_test 2.1 { 58 do_catchsql_test 2.1 {
58 CREATE VIRTUAL TABLE x2 USING fts4(mtchinfo=fts3); 59 CREATE VIRTUAL TABLE x2 USING fts4(mtchinfo=fts3);
59 } {1 {unrecognized parameter: mtchinfo=fts3}} 60 } {1 {unrecognized parameter: mtchinfo=fts3}}
61 do_catchsql_test 2.2 {
62 CREATE VIRTUAL TABLE x2 USING fts4(matchinfo=fts5);
63 } {1 {unrecognized matchinfo: fts5}}
60 64
61 # Check that with fts3, the "=" character is permitted in column definitions. 65 # Check that with fts3, the "=" character is permitted in column definitions.
62 # 66 #
63 do_execsql_test 3.1 { 67 do_execsql_test 3.1 {
64 CREATE VIRTUAL TABLE t3 USING fts3(mtchinfo=fts3); 68 CREATE VIRTUAL TABLE t3 USING fts3(mtchinfo=fts3);
65 INSERT INTO t3(mtchinfo) VALUES('Beside the lake, beneath the trees'); 69 INSERT INTO t3(mtchinfo) VALUES('Beside the lake, beneath the trees');
66 SELECT mtchinfo FROM t3; 70 SELECT mtchinfo FROM t3;
67 } {{Beside the lake, beneath the trees}} 71 } {{Beside the lake, beneath the trees}}
68 72
69 do_execsql_test 3.2 { 73 do_execsql_test 3.2 {
70 CREATE VIRTUAL TABLE xx USING FTS4; 74 CREATE VIRTUAL TABLE xx USING FTS4;
75 }
76 do_execsql_test 3.3 {
71 SELECT * FROM xx WHERE xx MATCH 'abc'; 77 SELECT * FROM xx WHERE xx MATCH 'abc';
78 }
79 do_execsql_test 3.4 {
72 SELECT * FROM xx WHERE xx MATCH 'a b c'; 80 SELECT * FROM xx WHERE xx MATCH 'a b c';
73 } 81 }
74 82
75 83
76 #-------------------------------------------------------------------------- 84 #--------------------------------------------------------------------------
77 # Proc [do_matchinfo_test] is used to test the FTSX matchinfo() function. 85 # Proc [do_matchinfo_test] is used to test the FTSX matchinfo() function.
78 # 86 #
79 # The first argument - $tn - is a test identifier. This may be either a 87 # The first argument - $tn - is a test identifier. This may be either a
80 # full identifier (i.e. "fts3matchinfo-1.1") or, if global var $testprefix 88 # full identifier (i.e. "fts3matchinfo-1.1") or, if global var $testprefix
81 # is set, just the numeric component (i.e. "1.1"). 89 # is set, just the numeric component (i.e. "1.1").
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 s {{0 1} {1 0}} 221 s {{0 1} {1 0}}
214 222
215 xxxxxxxxxxxxxxxxxx - pcx - xpc - ccc - pppxpcpcx - laxnpc - 223 xxxxxxxxxxxxxxxxxx - pcx - xpc - ccc - pppxpcpcx - laxnpc -
216 sxsxs - 224 sxsxs -
217 } 225 }
218 226
219 do_matchinfo_test 4.1.3 t4 {t4 MATCH 'a b'} { s {{2 0} {0 2}} } 227 do_matchinfo_test 4.1.3 t4 {t4 MATCH 'a b'} { s {{2 0} {0 2}} }
220 do_matchinfo_test 4.1.4 t4 {t4 MATCH '"a b" c'} { s {{2 0} {0 2}} } 228 do_matchinfo_test 4.1.4 t4 {t4 MATCH '"a b" c'} { s {{2 0} {0 2}} }
221 do_matchinfo_test 4.1.5 t4 {t4 MATCH 'a "b c"'} { s {{2 0} {0 2}} } 229 do_matchinfo_test 4.1.5 t4 {t4 MATCH 'a "b c"'} { s {{2 0} {0 2}} }
222 do_matchinfo_test 4.1.6 t4 {t4 MATCH 'd d'} { s {{1 0} {0 1}} } 230 do_matchinfo_test 4.1.6 t4 {t4 MATCH 'd d'} { s {{1 0} {0 1}} }
231 do_matchinfo_test 4.1.7 t4 {t4 MATCH 'f OR abcd'} {
232 x {
233 {0 1 1 1 1 1 0 0 0 0 0 0}
234 {1 1 1 0 1 1 0 0 0 0 0 0}
235 }
236 }
237 do_matchinfo_test 4.1.8 t4 {t4 MATCH 'f -abcd'} {
238 x {
239 {0 1 1 1 1 1}
240 {1 1 1 0 1 1}
241 }
242 }
223 243
224 do_execsql_test 4.2.0 { 244 do_execsql_test 4.2.0 {
225 CREATE VIRTUAL TABLE t5 USING fts4; 245 CREATE VIRTUAL TABLE t5 USING fts4;
226 INSERT INTO t5 VALUES('a a a a a'); 246 INSERT INTO t5 VALUES('a a a a a');
227 INSERT INTO t5 VALUES('a b a b a'); 247 INSERT INTO t5 VALUES('a b a b a');
228 INSERT INTO t5 VALUES('c b c b c'); 248 INSERT INTO t5 VALUES('c b c b c');
229 INSERT INTO t5 VALUES('x x x x x'); 249 INSERT INTO t5 VALUES('x x x x x');
230 } 250 }
231 do_matchinfo_test 4.2.1 t5 {t5 MATCH 'a a'} { 251 do_matchinfo_test 4.2.1 t5 {t5 MATCH 'a a'} {
232 x {{5 8 2 5 8 2} {3 8 2 3 8 2}} 252 x {{5 8 2 5 8 2} {3 8 2 3 8 2}}
233 s {2 1} 253 s {2 1}
234 } 254 }
235 do_matchinfo_test 4.2.2 t5 {t5 MATCH 'a b'} { s {2} } 255 do_matchinfo_test 4.2.2 t5 {t5 MATCH 'a b'} { s {2} }
236 do_matchinfo_test 4.2.3 t5 {t5 MATCH 'a b a'} { s {3} } 256 do_matchinfo_test 4.2.3 t5 {t5 MATCH 'a b a'} { s {3} }
237 do_matchinfo_test 4.2.4 t5 {t5 MATCH 'a a a'} { s {3 1} } 257 do_matchinfo_test 4.2.4 t5 {t5 MATCH 'a a a'} { s {3 1} }
238 do_matchinfo_test 4.2.5 t5 {t5 MATCH '"a b" "a b"'} { s {2} } 258 do_matchinfo_test 4.2.5 t5 {t5 MATCH '"a b" "a b"'} { s {2} }
239 do_matchinfo_test 4.2.6 t5 {t5 MATCH 'a OR b'} { s {1 2 1} } 259 do_matchinfo_test 4.2.6 t5 {t5 MATCH 'a OR b'} { s {1 2 1} }
240 260
241 do_execsql_test 4.3.0 "INSERT INTO t5 VALUES('x y [string repeat {b } 50000]')"; 261 do_execsql_test 4.3.0 "INSERT INTO t5 VALUES('x y [string repeat {b } 50000]')";
242 262
243 do_matchinfo_test 4.3.1 t5 {t5 MATCH 'a a'} { 263 # It used to be that the second 'a' token would be deferred. That doesn't
244 x {{5 8 2 5 5 5} {3 8 2 3 5 5}} 264 # work any longer.
245 s {2 1} 265 if 0 {
266 do_matchinfo_test 4.3.1 t5 {t5 MATCH 'a a'} {
267 x {{5 8 2 5 5 5} {3 8 2 3 5 5}}
268 s {2 1}
269 }
246 } 270 }
247 271
248 do_matchinfo_test 4.3.2 t5 {t5 MATCH 'a b'} { s {2} } 272 do_matchinfo_test 4.3.2 t5 {t5 MATCH 'a b'} { s {2} }
249 do_matchinfo_test 4.3.3 t5 {t5 MATCH 'a b a'} { s {3} } 273 do_matchinfo_test 4.3.3 t5 {t5 MATCH 'a b a'} { s {3} }
250 do_matchinfo_test 4.3.4 t5 {t5 MATCH 'a a a'} { s {3 1} } 274 do_matchinfo_test 4.3.4 t5 {t5 MATCH 'a a a'} { s {3 1} }
251 do_matchinfo_test 4.3.5 t5 {t5 MATCH '"a b" "a b"'} { s {2} } 275 do_matchinfo_test 4.3.5 t5 {t5 MATCH '"a b" "a b"'} { s {2} }
252 do_matchinfo_test 4.3.6 t5 {t5 MATCH 'a OR b'} { s {1 2 1 1} } 276 do_matchinfo_test 4.3.6 t5 {t5 MATCH 'a OR b'} { s {1 2 1 1} }
253 277
254 do_execsql_test 4.4.0 { 278 do_execsql_test 4.4.0.1 { INSERT INTO t5(t5) VALUES('optimize') }
255 INSERT INTO t5(t5) VALUES('optimize'); 279
256 UPDATE t5_segments 280 ifcapable fts4_deferred {
257 SET block = zeroblob(length(block)) 281 do_execsql_test 4.4.0.2 {
258 WHERE length(block)>10000; 282 UPDATE t5_segments
283 SET block = zeroblob(length(block))
284 WHERE length(block)>10000;
285 }
259 } 286 }
260 287
261 do_matchinfo_test 4.4.2 t5 {t5 MATCH 'a b'} { s {2} } 288 do_matchinfo_test 4.4.2 t5 {t5 MATCH 'a b'} { s {2} }
262 do_matchinfo_test 4.4.1 t5 {t5 MATCH 'a a'} { s {2 1} } 289 do_matchinfo_test 4.4.1 t5 {t5 MATCH 'a a'} { s {2 1} }
263 do_matchinfo_test 4.4.2 t5 {t5 MATCH 'a b'} { s {2} } 290 do_matchinfo_test 4.4.2 t5 {t5 MATCH 'a b'} { s {2} }
264 do_matchinfo_test 4.4.3 t5 {t5 MATCH 'a b a'} { s {3} } 291 do_matchinfo_test 4.4.3 t5 {t5 MATCH 'a b a'} { s {3} }
265 do_matchinfo_test 4.4.4 t5 {t5 MATCH 'a a a'} { s {3 1} } 292 do_matchinfo_test 4.4.4 t5 {t5 MATCH 'a a a'} { s {3 1} }
266 do_matchinfo_test 4.4.5 t5 {t5 MATCH '"a b" "a b"'} { s {2} } 293 do_matchinfo_test 4.4.5 t5 {t5 MATCH '"a b" "a b"'} { s {2} }
267 294
268 do_execsql_test 4.5.0 { 295 do_execsql_test 4.5.0 {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 do_execsql_test 8.4.2.1 { UPDATE t11_stat SET value = X'00'; } 400 do_execsql_test 8.4.2.1 { UPDATE t11_stat SET value = X'00'; }
374 do_catchsql_test 8.5.2.2 { 401 do_catchsql_test 8.5.2.2 {
375 SELECT mit(matchinfo(t11, 'nxa')) FROM t11 WHERE t11 MATCH 'a*' 402 SELECT mit(matchinfo(t11, 'nxa')) FROM t11 WHERE t11 MATCH 'a*'
376 } {1 {database disk image is malformed}} 403 } {1 {database disk image is malformed}}
377 404
378 do_execsql_test 8.4.3.1 { UPDATE t11_stat SET value = NULL; } 405 do_execsql_test 8.4.3.1 { UPDATE t11_stat SET value = NULL; }
379 do_catchsql_test 8.5.3.2 { 406 do_catchsql_test 8.5.3.2 {
380 SELECT mit(matchinfo(t11, 'nxa')) FROM t11 WHERE t11 MATCH 'a*' 407 SELECT mit(matchinfo(t11, 'nxa')) FROM t11 WHERE t11 MATCH 'a*'
381 } {1 {database disk image is malformed}} 408 } {1 {database disk image is malformed}}
382 409
410 #-------------------------------------------------------------------------
411 do_execsql_test 8.1 {
412 CREATE VIRTUAL TABLE t12 USING fts4;
413 INSERT INTO t12 VALUES('a b c d');
414 SELECT mit(matchinfo(t12, 'x')) FROM t12 WHERE t12 MATCH 'a NEAR/1 d OR a';
415 } {{0 0 0 0 0 0 1 1 1}}
416 do_execsql_test 8.2 {
417 INSERT INTO t12 VALUES('a d c d');
418 SELECT mit(matchinfo(t12, 'x')) FROM t12 WHERE t12 MATCH 'a NEAR/1 d OR a';
419 } {
420 {0 1 1 0 1 1 1 2 2} {1 1 1 1 1 1 1 2 2}
421 }
422 do_execsql_test 8.3 {
423 INSERT INTO t12 VALUES('a d d a');
424 SELECT mit(matchinfo(t12, 'x')) FROM t12 WHERE t12 MATCH 'a NEAR/1 d OR a';
425 } {
426 {0 3 2 0 3 2 1 4 3} {1 3 2 1 3 2 1 4 3} {2 3 2 2 3 2 2 4 3}
427 }
428
429 do_execsql_test 9.1 {
430 CREATE VIRTUAL TABLE ft2 USING fts4;
431 INSERT INTO ft2 VALUES('a b c d e');
432 INSERT INTO ft2 VALUES('f a b c d');
433 SELECT snippet(ft2, '[', ']', '', -1, 1) FROM ft2 WHERE ft2 MATCH 'c';
434 } {{[c]} {[c]}}
435
436 #---------------------------------------------------------------------------
437 # Test for a memory leak
438 #
439 do_execsql_test 10.1 {
440 DROP TABLE t10;
441 CREATE VIRTUAL TABLE t10 USING fts4(idx, value);
442 INSERT INTO t10 values (1, 'one'),(2, 'two'),(3, 'three');
443 SELECT docId, t10.*
444 FROM t10
445 JOIN (SELECT 1 AS idx UNION SELECT 2 UNION SELECT 3) AS x
446 WHERE t10 MATCH x.idx
447 AND matchinfo(t10) not null
448 GROUP BY docId
449 ORDER BY 1;
450 } {1 1 one 2 2 two 3 3 three}
451
452
383 finish_test 453 finish_test
384
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698