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 #*************************************************************************
11 # This file implements regression tests for SQLite library. The
12 # focus of this script is testing the FTS5 module.
15 source [file join [file dirname [info script]] fts5_common.tcl]
16 set testprefix fts5multi
18 # If SQLITE_ENABLE_FTS5 is not defined, omit this file.
24 fts5_aux_test_functions db
27 CREATE VIRTUAL TABLE t1 USING fts5(a, b, c);
28 INSERT INTO t1 VALUES('gg bb bb' ,'gg ff gg' ,'ii ii');
29 INSERT INTO t1 VALUES('dd dd hh kk','jj' ,'aa');
30 INSERT INTO t1 VALUES('kk gg ee' ,'hh cc' ,'hh jj aa cc');
31 INSERT INTO t1 VALUES('hh' ,'bb jj cc' ,'kk ii');
32 INSERT INTO t1 VALUES('kk dd kk ii','aa ee aa' ,'ee');
33 INSERT INTO t1 VALUES('ee' ,'ff gg kk aa','ee ff ee');
34 INSERT INTO t1 VALUES('ff jj' ,'gg ee' ,'kk ee gg kk');
35 INSERT INTO t1 VALUES('ff ee dd hh','kk ee' ,'gg dd');
36 INSERT INTO t1 VALUES('bb' ,'aa' ,'bb aa');
37 INSERT INTO t1 VALUES('hh cc bb' ,'ff bb' ,'cc');
38 INSERT INTO t1 VALUES('jj' ,'ff dd bb aa','dd dd ff ff');
39 INSERT INTO t1 VALUES('ff dd gg dd','gg aa bb ff','cc');
40 INSERT INTO t1 VALUES('ff aa cc jj','kk' ,'ii dd');
41 INSERT INTO t1 VALUES('jj dd' ,'cc' ,'ii hh ee aa');
42 INSERT INTO t1 VALUES('ff ii hh' ,'dd' ,'gg');
43 INSERT INTO t1 VALUES('ff dd gg hh','hh' ,'ff dd');
44 INSERT INTO t1 VALUES('cc cc' ,'ff dd ff' ,'bb');
45 INSERT INTO t1 VALUES('ii' ,'bb ii' ,'jj kk');
46 INSERT INTO t1 VALUES('ff hh' ,'hh bb' ,'bb dd ee');
47 INSERT INTO t1 VALUES('jj kk' ,'jj' ,'gg ff cc');
48 INSERT INTO t1 VALUES('dd kk' ,'ii gg' ,'dd');
49 INSERT INTO t1 VALUES('cc' ,'aa ff' ,'ii');
50 INSERT INTO t1 VALUES('bb ff bb ii','bb kk bb aa','hh ff ii dd');
51 INSERT INTO t1 VALUES('aa' ,'ee bb jj jj','dd');
52 INSERT INTO t1 VALUES('kk dd cc' ,'aa jj' ,'ee aa ff');
53 INSERT INTO t1 VALUES('aa gg aa' ,'jj' ,'ii kk hh gg');
54 INSERT INTO t1 VALUES('ff hh aa' ,'jj ii' ,'hh dd bb jj');
55 INSERT INTO t1 VALUES('hh' ,'aa gg kk' ,'bb ee');
56 INSERT INTO t1 VALUES('bb' ,'ee' ,'gg');
57 INSERT INTO t1 VALUES('dd kk' ,'kk bb aa' ,'ee');
60 foreach {tn c1 e1 c2 e2} {
63 3 a "aa OR bb OR cc" b "jj OR ii OR hh"
64 4 t1 "aa AND bb" t1 "cc"
65 5 c "kk" b "aa OR bb OR cc OR dd OR ee"
70 set lhs "$c1 : ( $e1 )"
75 set rhs "$c2 : ( $e2 )"
78 set q1 "t1 MATCH '($lhs) AND ($rhs)'"
79 set q2 "$c1 MATCH '$e1' AND $c2 MATCH '$e2'"
81 set ret [execsql "SELECT rowid FROM t1 WHERE $q1"]
83 do_execsql_test 1.$tn.1.($N) "SELECT rowid FROM t1 WHERE $q2" $ret
85 set ret [execsql "SELECT fts5_test_poslist(t1) FROM t1 WHERE $q1"]
86 do_execsql_test 1.$tn.2.($N) "
87 SELECT fts5_test_poslist(t1) FROM t1 WHERE $q2
91 do_catchsql_test 2.1.1 {
92 SELECT rowid FROM t1 WHERE t1 MATCH '(NOT' AND t1 MATCH 'aa bb';
93 } {1 {fts5: syntax error near "NOT"}}
94 do_catchsql_test 2.1.2 {
95 SELECT rowid FROM t1 WHERE t1 MATCH 'aa bb' AND t1 MATCH '(NOT';
96 } {1 {fts5: syntax error near "NOT"}}