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

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

Issue 1610963002: Import SQLite 3.10.2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 #***********************************************************************
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 INSERT INTO t10 values (1, 'one'),(2, 'two'),(3, 'three'); 442 INSERT INTO t10 values (1, 'one'),(2, 'two'),(3, 'three');
443 SELECT docId, t10.* 443 SELECT docId, t10.*
444 FROM t10 444 FROM t10
445 JOIN (SELECT 1 AS idx UNION SELECT 2 UNION SELECT 3) AS x 445 JOIN (SELECT 1 AS idx UNION SELECT 2 UNION SELECT 3) AS x
446 WHERE t10 MATCH x.idx 446 WHERE t10 MATCH x.idx
447 AND matchinfo(t10) not null 447 AND matchinfo(t10) not null
448 GROUP BY docId 448 GROUP BY docId
449 ORDER BY 1; 449 ORDER BY 1;
450 } {1 1 one 2 2 two 3 3 three} 450 } {1 1 one 2 2 two 3 3 three}
451 451
452 #---------------------------------------------------------------------------
453 # Test the 'y' matchinfo flag
454 #
455 set sqlite_fts3_enable_parentheses 1
456 reset_db
457 do_execsql_test 11.0 {
458 CREATE VIRTUAL TABLE tt USING fts3(x, y);
459 INSERT INTO tt VALUES('c d a c d d', 'e a g b d a'); -- 1
460 INSERT INTO tt VALUES('c c g a e b', 'c g d g e c'); -- 2
461 INSERT INTO tt VALUES('b e f d e g', 'b a c b c g'); -- 3
462 INSERT INTO tt VALUES('a c f f g d', 'd b f d e g'); -- 4
463 INSERT INTO tt VALUES('g a c f c f', 'd g g b c c'); -- 5
464 INSERT INTO tt VALUES('g a c e b b', 'd b f b g g'); -- 6
465 INSERT INTO tt VALUES('f d a a f c', 'e e a d c f'); -- 7
466 INSERT INTO tt VALUES('a c b b g f', 'a b a e d f'); -- 8
467 INSERT INTO tt VALUES('b a f e c c', 'f d b b a b'); -- 9
468 INSERT INTO tt VALUES('f d c e a c', 'f a f a a f'); -- 10
469 }
452 470
471 db func mit mit
472 foreach {tn expr res} {
473 1 "a" {
474 1 {1 2} 2 {1 0} 3 {0 1} 4 {1 0} 5 {1 0}
475 6 {1 0} 7 {2 1} 8 {1 2} 9 {1 1} 10 {1 3}
476 }
477
478 2 "b" {
479 1 {0 1} 2 {1 0} 3 {1 2} 4 {0 1} 5 {0 1}
480 6 {2 2} 8 {2 1} 9 {1 3}
481 }
482
483 3 "y:a" {
484 1 {0 2} 3 {0 1}
485 7 {0 1} 8 {0 2} 9 {0 1} 10 {0 3}
486 }
487
488 4 "x:a" {
489 1 {1 0} 2 {1 0} 4 {1 0} 5 {1 0}
490 6 {1 0} 7 {2 0} 8 {1 0} 9 {1 0} 10 {1 0}
491 }
492
493 5 "a OR b" {
494 1 {1 2 0 1} 2 {1 0 1 0} 3 {0 1 1 2} 4 {1 0 0 1} 5 {1 0 0 1}
495 6 {1 0 2 2} 7 {2 1 0 0} 8 {1 2 2 1} 9 {1 1 1 3} 10 {1 3 0 0}
496 }
497
498 6 "a AND b" {
499 1 {1 2 0 1} 2 {1 0 1 0} 3 {0 1 1 2} 4 {1 0 0 1} 5 {1 0 0 1}
500 6 {1 0 2 2} 8 {1 2 2 1} 9 {1 1 1 3}
501 }
502
503 7 "a OR (a AND b)" {
504 1 {1 2 1 2 0 1} 2 {1 0 1 0 1 0} 3 {0 1 0 1 1 2} 4 {1 0 1 0 0 1}
505 5 {1 0 1 0 0 1} 6 {1 0 1 0 2 2} 7 {2 1 0 0 0 0} 8 {1 2 1 2 2 1}
506 9 {1 1 1 1 1 3} 10 {1 3 0 0 0 0}
507 }
508
509 } {
510 do_execsql_test 11.1.$tn.1 {
511 SELECT rowid, mit(matchinfo(tt, 'y')) FROM tt WHERE tt MATCH $expr
512 } $res
513
514 set r2 [list]
515 foreach {rowid L} $res {
516 lappend r2 $rowid
517 set M [list]
518 foreach {a b} $L {
519 lappend M [expr ($a ? 1 : 0) + ($b ? 2 : 0)]
520 }
521 lappend r2 $M
522 }
523
524 do_execsql_test 11.1.$tn.2 {
525 SELECT rowid, mit(matchinfo(tt, 'b')) FROM tt WHERE tt MATCH $expr
526 } $r2
527 breakpoint
528
529 do_execsql_test 11.1.$tn.2 {
530 SELECT rowid, mit(matchinfo(tt, 'b')) FROM tt WHERE tt MATCH $expr
531 } $r2
532 }
533 set sqlite_fts3_enable_parentheses 0
534
535 #---------------------------------------------------------------------------
536 # Test the 'b' matchinfo flag
537 #
538 set sqlite_fts3_enable_parentheses 1
539 reset_db
540 db func mit mit
541
542 do_test 12.0 {
543 set cols [list]
544 for {set i 0} {$i < 50} {incr i} { lappend cols "c$i" }
545 execsql "CREATE VIRTUAL TABLE tt USING fts3([join $cols ,])"
546 } {}
547
548 do_execsql_test 12.1 {
549 INSERT INTO tt (rowid, c4, c45) VALUES(1, 'abc', 'abc');
550 SELECT mit(matchinfo(tt, 'b')) FROM tt WHERE tt MATCH 'abc';
551 } [list [list [expr 1<<4] [expr 1<<(45-32)]]]
552
553 set sqlite_fts3_enable_parentheses 0
453 finish_test 554 finish_test
555
OLDNEW
« no previous file with comments | « third_party/sqlite/src/test/fts3fault2.test ('k') | third_party/sqlite/src/test/fts3offsets.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698