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

Unified Diff: third_party/sqlite/src/ext/fts5/test/fts5matchinfo.test

Issue 2751253002: [sql] Import SQLite 3.17.0. (Closed)
Patch Set: also clang on Linux i386 Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: third_party/sqlite/src/ext/fts5/test/fts5matchinfo.test
diff --git a/third_party/sqlite/src/ext/fts5/test/fts5matchinfo.test b/third_party/sqlite/src/ext/fts5/test/fts5matchinfo.test
index 21f9b003e70becc32592b08410cd636a2161c87b..99b07677af2aaf315ecd53eb1b11e2fb993fd269 100644
--- a/third_party/sqlite/src/ext/fts5/test/fts5matchinfo.test
+++ b/third_party/sqlite/src/ext/fts5/test/fts5matchinfo.test
@@ -16,6 +16,8 @@ set testprefix fts5matchinfo
# If SQLITE_ENABLE_FTS5 is not defined, omit this file.
ifcapable !fts5 { finish_test ; return }
+foreach_detail_mode $testprefix {
+
proc mit {blob} {
set scan(littleEndian) i*
set scan(bigEndian) I*
@@ -27,7 +29,7 @@ db func mit mit
sqlite3_fts5_register_matchinfo db
do_execsql_test 1.0 {
- CREATE VIRTUAL TABLE t1 USING fts5(content);
+ CREATE VIRTUAL TABLE t1 USING fts5(content, detail=%DETAIL%);
}
do_execsql_test 1.1 {
@@ -41,7 +43,7 @@ do_execsql_test 1.1 {
# Now create an FTS4 table that does not specify matchinfo=fts3.
#
do_execsql_test 1.2 {
- CREATE VIRTUAL TABLE t2 USING fts5(content);
+ CREATE VIRTUAL TABLE t2 USING fts5(content, detail=%DETAIL%);
INSERT INTO t2 SELECT * FROM t1;
SELECT mit(matchinfo(t2)) FROM t2 WHERE t2 MATCH 'I';
} {{1 1 1 2 2} {1 1 1 2 2}}
@@ -149,9 +151,17 @@ proc normalize2 {list_of_lists} {
return $res
}
+# Similar to [do_matchinfo_test], except that this is a no-op if the FTS5
+# mode is not detail=full.
+#
+proc do_matchinfo_p_test {tn tbl expr results} {
+ if {[detail_is_full]} {
+ uplevel [list do_matchinfo_test $tn $tbl $expr $results]
+ }
+}
do_execsql_test 4.1.0 {
- CREATE VIRTUAL TABLE t4 USING fts5(x, y);
+ CREATE VIRTUAL TABLE t4 USING fts5(x, y, detail=%DETAIL%);
INSERT INTO t4 VALUES('a b c d e', 'f g h i j');
INSERT INTO t4 VALUES('f g h i j', 'a b c d e');
}
@@ -185,7 +195,7 @@ do_matchinfo_test 4.1.1 t4 {t4 MATCH 'a b c'} {
xpxsscplax -
}
-do_matchinfo_test 4.1.2 t4 {t4 MATCH '"g h i"'} {
+do_matchinfo_p_test 4.1.2 t4 {t4 MATCH '"g h i"'} {
p {1 1}
c {2 2}
x {
@@ -203,8 +213,8 @@ do_matchinfo_test 4.1.2 t4 {t4 MATCH '"g h i"'} {
}
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_p_test 4.1.4 t4 {t4 MATCH '"a b" c'} { s {{2 0} {0 2}} }
+do_matchinfo_p_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 {
@@ -220,7 +230,7 @@ do_matchinfo_test 4.1.8 t4 {t4 MATCH 'f NOT abcd'} {
}
do_execsql_test 4.2.0 {
- CREATE VIRTUAL TABLE t5 USING fts5(content);
+ CREATE VIRTUAL TABLE t5 USING fts5(content, detail=%DETAIL%);
INSERT INTO t5 VALUES('a a a a a');
INSERT INTO t5 VALUES('a b a b a');
INSERT INTO t5 VALUES('c b c b c');
@@ -233,7 +243,7 @@ do_matchinfo_test 4.2.1 t5 {t5 MATCH 'a a'} {
do_matchinfo_test 4.2.2 t5 {t5 MATCH 'a b'} { s {2} }
do_matchinfo_test 4.2.3 t5 {t5 MATCH 'a b a'} { s {3} }
do_matchinfo_test 4.2.4 t5 {t5 MATCH 'a a a'} { s {3 1} }
-do_matchinfo_test 4.2.5 t5 {t5 MATCH '"a b" "a b"'} { s {2} }
+do_matchinfo_p_test 4.2.5 t5 {t5 MATCH '"a b" "a b"'} { s {2} }
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]')";
@@ -250,7 +260,7 @@ if 0 {
do_matchinfo_test 4.3.2 t5 {t5 MATCH 'a b'} { s {2} }
do_matchinfo_test 4.3.3 t5 {t5 MATCH 'a b a'} { s {3} }
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_p_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.1 { INSERT INTO t5(t5) VALUES('optimize') }
@@ -260,10 +270,10 @@ do_matchinfo_test 4.4.1 t5 {t5 MATCH 'a a'} { s {2 1} }
do_matchinfo_test 4.4.2 t5 {t5 MATCH 'a b'} { s {2} }
do_matchinfo_test 4.4.3 t5 {t5 MATCH 'a b a'} { s {3} }
do_matchinfo_test 4.4.4 t5 {t5 MATCH 'a a a'} { s {3 1} }
-do_matchinfo_test 4.4.5 t5 {t5 MATCH '"a b" "a b"'} { s {2} }
+do_matchinfo_p_test 4.4.5 t5 {t5 MATCH '"a b" "a b"'} { s {2} }
do_execsql_test 4.5.0 {
- CREATE VIRTUAL TABLE t6 USING fts5(a, b, c);
+ CREATE VIRTUAL TABLE t6 USING fts5(a, b, c, detail=%DETAIL%);
INSERT INTO t6 VALUES('a', 'b', 'c');
}
do_matchinfo_test 4.5.1 t6 {t6 MATCH 'a b c'} { s {{1 1 1}} }
@@ -274,7 +284,7 @@ do_matchinfo_test 4.5.1 t6 {t6 MATCH 'a b c'} { s {{1 1 1}} }
# use the full-text index (i.e. lookup by rowid or full-table scan).
#
do_execsql_test 7.1 {
- CREATE VIRTUAL TABLE t10 USING fts5(content);
+ CREATE VIRTUAL TABLE t10 USING fts5(content, detail=%DETAIL%);
INSERT INTO t10 VALUES('first record');
INSERT INTO t10 VALUES('second record');
}
@@ -299,7 +309,7 @@ do_execsql_test 7.4 {
# SELECT sum(length(content)) < count(*) FROM fts4table;
#
do_execsql_test 8.1 {
- CREATE VIRTUAL TABLE t11 USING fts5(content);
+ CREATE VIRTUAL TABLE t11 USING fts5(content, detail=%DETAIL%);
INSERT INTO t11(t11, rank) VALUES('pgsz', 32);
INSERT INTO t11 VALUES('quitealongstringoftext');
INSERT INTO t11 VALUES('anotherquitealongstringoftext');
@@ -318,22 +328,24 @@ do_execsql_test 8.3 {
#-------------------------------------------------------------------------
-do_execsql_test 9.1 {
- CREATE VIRTUAL TABLE t12 USING fts5(content);
- INSERT INTO t12 VALUES('a b c d');
- SELECT mit(matchinfo(t12, 'x')) FROM t12 WHERE t12 MATCH 'NEAR(a d, 1) OR a';
-} {{0 1 1 0 1 1 1 1 1}}
-do_execsql_test 9.2 {
- INSERT INTO t12 VALUES('a d c d');
- SELECT mit(matchinfo(t12, 'x')) FROM t12 WHERE t12 MATCH 'NEAR(a d, 1) OR a';
-} {
- {0 2 2 0 3 2 1 2 2} {1 2 2 1 3 2 1 2 2}
-}
-do_execsql_test 9.3 {
- INSERT INTO t12 VALUES('a d d a');
- SELECT mit(matchinfo(t12, 'x')) FROM t12 WHERE t12 MATCH 'NEAR(a d, 1) OR a';
-} {
- {0 4 3 0 5 3 1 4 3} {1 4 3 1 5 3 1 4 3} {2 4 3 2 5 3 2 4 3}
+if {[detail_is_full]} {
+ do_execsql_test 9.1 {
+ CREATE VIRTUAL TABLE t12 USING fts5(content, detail=%DETAIL%);
+ INSERT INTO t12 VALUES('a b c d');
+ SELECT mit(matchinfo(t12,'x')) FROM t12 WHERE t12 MATCH 'NEAR(a d, 1) OR a';
+ } {{0 1 1 0 1 1 1 1 1}}
+ do_execsql_test 9.2 {
+ INSERT INTO t12 VALUES('a d c d');
+ SELECT mit(matchinfo(t12,'x')) FROM t12 WHERE t12 MATCH 'NEAR(a d, 1) OR a';
+ } {
+ {0 2 2 0 3 2 1 2 2} {1 2 2 1 3 2 1 2 2}
+ }
+ do_execsql_test 9.3 {
+ INSERT INTO t12 VALUES('a d d a');
+ SELECT mit(matchinfo(t12,'x')) FROM t12 WHERE t12 MATCH 'NEAR(a d, 1) OR a';
+ } {
+ {0 4 3 0 5 3 1 4 3} {1 4 3 1 5 3 1 4 3} {2 4 3 2 5 3 2 4 3}
+ }
}
#---------------------------------------------------------------------------
@@ -341,7 +353,7 @@ do_execsql_test 9.3 {
#
do_execsql_test 10.1 {
DROP TABLE t10;
- CREATE VIRTUAL TABLE t10 USING fts5(idx, value);
+ CREATE VIRTUAL TABLE t10 USING fts5(idx, value, detail=%DETAIL%);
INSERT INTO t10 values (1, 'one'),(2, 'two'),(3, 'three');
SELECT t10.rowid, t10.*
FROM t10
@@ -358,7 +370,7 @@ do_execsql_test 10.1 {
reset_db
sqlite3_fts5_register_matchinfo db
do_execsql_test 11.0 {
- CREATE VIRTUAL TABLE tt USING fts5(x, y);
+ CREATE VIRTUAL TABLE tt USING fts5(x, y, detail=%DETAIL%);
INSERT INTO tt VALUES('c d a c d d', 'e a g b d a'); -- 1
INSERT INTO tt VALUES('c c g a e b', 'c g d g e c'); -- 2
INSERT INTO tt VALUES('b e f d e g', 'b a c b c g'); -- 3
@@ -410,6 +422,8 @@ foreach {tn expr res} {
}
} {
+
+ if {[string match *:* $expr] && [detail_is_none]} continue
do_execsql_test 11.1.$tn.1 {
SELECT rowid, mit(matchinfo(tt, 'y')) FROM tt WHERE tt MATCH $expr
} $res
@@ -443,7 +457,7 @@ db func mit mit
do_test 12.0 {
set cols [list]
for {set i 0} {$i < 50} {incr i} { lappend cols "c$i" }
- execsql "CREATE VIRTUAL TABLE tt USING fts5([join $cols ,])"
+ execsql "CREATE VIRTUAL TABLE tt USING fts5([join $cols ,], detail=%DETAIL%)"
} {}
do_execsql_test 12.1 {
@@ -451,5 +465,31 @@ do_execsql_test 12.1 {
SELECT mit(matchinfo(tt, 'b')) FROM tt WHERE tt MATCH 'abc';
} [list [list [expr 1<<4] [expr 1<<(45-32)]]]
+} ;# foreach_detail_mode
+
+#-------------------------------------------------------------------------
+# Test that a bad fts5() return is detected
+#
+reset_db
+proc xyz {} {}
+db func fts5 -argcount 0 xyz
+do_test 13.1 {
+ list [catch { sqlite3_fts5_register_matchinfo db } msg] $msg
+} {1 SQLITE_ERROR}
+
+#-------------------------------------------------------------------------
+# Test that an invalid matchinfo() flag is detected
+#
+reset_db
+sqlite3_fts5_register_matchinfo db
+do_execsql_test 14.1 {
+ CREATE VIRTUAL TABLE x1 USING fts5(z);
+ INSERT INTO x1 VALUES('a b c a b c a b c');
+} {}
+
+do_catchsql_test 14.2 {
+ SELECT matchinfo(x1, 'd') FROM x1('a b c');
+} {1 {unrecognized matchinfo flag: d}}
+
finish_test
« no previous file with comments | « third_party/sqlite/src/ext/fts5/test/fts5integrity.test ('k') | third_party/sqlite/src/ext/fts5/test/fts5merge.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698