Index: third_party/sqlite/src/test/fts3matchinfo.test |
diff --git a/third_party/sqlite/src/test/fts3matchinfo.test b/third_party/sqlite/src/test/fts3matchinfo.test |
index 8f194e72cb38f078472393041643557474b4dca5..36c91211180e6f6b25078d0883fae0c2bc0fdb38 100644 |
--- a/third_party/sqlite/src/test/fts3matchinfo.test |
+++ b/third_party/sqlite/src/test/fts3matchinfo.test |
@@ -19,6 +19,7 @@ source $testdir/tester.tcl |
ifcapable !fts3 { finish_test ; return } |
set testprefix fts3matchinfo |
+set sqlite_fts3_enable_parentheses 0 |
proc mit {blob} { |
set scan(littleEndian) i* |
@@ -57,6 +58,9 @@ do_catchsql_test 2.0 { |
do_catchsql_test 2.1 { |
CREATE VIRTUAL TABLE x2 USING fts4(mtchinfo=fts3); |
} {1 {unrecognized parameter: mtchinfo=fts3}} |
+do_catchsql_test 2.2 { |
+ CREATE VIRTUAL TABLE x2 USING fts4(matchinfo=fts5); |
+} {1 {unrecognized matchinfo: fts5}} |
# Check that with fts3, the "=" character is permitted in column definitions. |
# |
@@ -68,7 +72,11 @@ do_execsql_test 3.1 { |
do_execsql_test 3.2 { |
CREATE VIRTUAL TABLE xx USING FTS4; |
+} |
+do_execsql_test 3.3 { |
SELECT * FROM xx WHERE xx MATCH 'abc'; |
+} |
+do_execsql_test 3.4 { |
SELECT * FROM xx WHERE xx MATCH 'a b c'; |
} |
@@ -220,6 +228,18 @@ do_matchinfo_test 4.1.3 t4 {t4 MATCH 'a b'} { s {{2 0} {0 2}} } |
do_matchinfo_test 4.1.4 t4 {t4 MATCH '"a b" c'} { s {{2 0} {0 2}} } |
do_matchinfo_test 4.1.5 t4 {t4 MATCH 'a "b c"'} { s {{2 0} {0 2}} } |
do_matchinfo_test 4.1.6 t4 {t4 MATCH 'd d'} { s {{1 0} {0 1}} } |
+do_matchinfo_test 4.1.7 t4 {t4 MATCH 'f OR abcd'} { |
+ x { |
+ {0 1 1 1 1 1 0 0 0 0 0 0} |
+ {1 1 1 0 1 1 0 0 0 0 0 0} |
+ } |
+} |
+do_matchinfo_test 4.1.8 t4 {t4 MATCH 'f -abcd'} { |
+ x { |
+ {0 1 1 1 1 1} |
+ {1 1 1 0 1 1} |
+ } |
+} |
do_execsql_test 4.2.0 { |
CREATE VIRTUAL TABLE t5 USING fts4; |
@@ -240,9 +260,13 @@ do_matchinfo_test 4.2.6 t5 {t5 MATCH 'a OR b'} { s {1 2 1} } |
do_execsql_test 4.3.0 "INSERT INTO t5 VALUES('x y [string repeat {b } 50000]')"; |
-do_matchinfo_test 4.3.1 t5 {t5 MATCH 'a a'} { |
- x {{5 8 2 5 5 5} {3 8 2 3 5 5}} |
- s {2 1} |
+# It used to be that the second 'a' token would be deferred. That doesn't |
+# work any longer. |
+if 0 { |
+ do_matchinfo_test 4.3.1 t5 {t5 MATCH 'a a'} { |
+ x {{5 8 2 5 5 5} {3 8 2 3 5 5}} |
+ s {2 1} |
+ } |
} |
do_matchinfo_test 4.3.2 t5 {t5 MATCH 'a b'} { s {2} } |
@@ -251,11 +275,14 @@ do_matchinfo_test 4.3.4 t5 {t5 MATCH 'a a a'} { s {3 1} } |
do_matchinfo_test 4.3.5 t5 {t5 MATCH '"a b" "a b"'} { s {2} } |
do_matchinfo_test 4.3.6 t5 {t5 MATCH 'a OR b'} { s {1 2 1 1} } |
-do_execsql_test 4.4.0 { |
- INSERT INTO t5(t5) VALUES('optimize'); |
- UPDATE t5_segments |
- SET block = zeroblob(length(block)) |
- WHERE length(block)>10000; |
+do_execsql_test 4.4.0.1 { INSERT INTO t5(t5) VALUES('optimize') } |
+ |
+ifcapable fts4_deferred { |
+ do_execsql_test 4.4.0.2 { |
+ UPDATE t5_segments |
+ SET block = zeroblob(length(block)) |
+ WHERE length(block)>10000; |
+ } |
} |
do_matchinfo_test 4.4.2 t5 {t5 MATCH 'a b'} { s {2} } |
@@ -380,5 +407,47 @@ do_catchsql_test 8.5.3.2 { |
SELECT mit(matchinfo(t11, 'nxa')) FROM t11 WHERE t11 MATCH 'a*' |
} {1 {database disk image is malformed}} |
-finish_test |
+#------------------------------------------------------------------------- |
+do_execsql_test 8.1 { |
+ CREATE VIRTUAL TABLE t12 USING fts4; |
+ INSERT INTO t12 VALUES('a b c d'); |
+ SELECT mit(matchinfo(t12, 'x')) FROM t12 WHERE t12 MATCH 'a NEAR/1 d OR a'; |
+} {{0 0 0 0 0 0 1 1 1}} |
+do_execsql_test 8.2 { |
+ INSERT INTO t12 VALUES('a d c d'); |
+ SELECT mit(matchinfo(t12, 'x')) FROM t12 WHERE t12 MATCH 'a NEAR/1 d OR a'; |
+} { |
+ {0 1 1 0 1 1 1 2 2} {1 1 1 1 1 1 1 2 2} |
+} |
+do_execsql_test 8.3 { |
+ INSERT INTO t12 VALUES('a d d a'); |
+ SELECT mit(matchinfo(t12, 'x')) FROM t12 WHERE t12 MATCH 'a NEAR/1 d OR a'; |
+} { |
+ {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} |
+} |
+ |
+do_execsql_test 9.1 { |
+ CREATE VIRTUAL TABLE ft2 USING fts4; |
+ INSERT INTO ft2 VALUES('a b c d e'); |
+ INSERT INTO ft2 VALUES('f a b c d'); |
+ SELECT snippet(ft2, '[', ']', '', -1, 1) FROM ft2 WHERE ft2 MATCH 'c'; |
+} {{[c]} {[c]}} |
+#--------------------------------------------------------------------------- |
+# Test for a memory leak |
+# |
+do_execsql_test 10.1 { |
+ DROP TABLE t10; |
+ CREATE VIRTUAL TABLE t10 USING fts4(idx, value); |
+ INSERT INTO t10 values (1, 'one'),(2, 'two'),(3, 'three'); |
+ SELECT docId, t10.* |
+ FROM t10 |
+ JOIN (SELECT 1 AS idx UNION SELECT 2 UNION SELECT 3) AS x |
+ WHERE t10 MATCH x.idx |
+ AND matchinfo(t10) not null |
+ GROUP BY docId |
+ ORDER BY 1; |
+} {1 1 one 2 2 two 3 3 three} |
+ |
+ |
+finish_test |