summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSachin Agarwal <sachin.z.agarwal@oracle.com>2020-10-26 12:21:29 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2020-10-26 12:21:29 +0200
commite391417f0fdbd746e23808b3d15d6cbe5a3b0aac (patch)
tree67abdcc7a4f85b1b199a205d0e6a758219d7e5af
parent784473b986625c25a7ab5b019bbbb9192102c731 (diff)
downloadmariadb-git-e391417f0fdbd746e23808b3d15d6cbe5a3b0aac.tar.gz
Bug #30933728 INNODB FTS PHRASE SEARCH HIT AN ASSERT
Problem: In Full-text phrase search, we filter out row that do not contain all the tokens in the phrase. If we do not filter out doc_id that doesn't appear in all the token's doc_id lists then we hit an assert. Fix: if any of the token has last doc_id equal to ith doc_id of the first token doc_id list then filter out rest of the higher doc_ids. RB: 24909 Reviewed by : Annamalai Gurusami <annamalai.gurusami@oracle.com> This is a cherry-pick of mysql/mysql-server@5aa075277dfe84a17a0331c57a6fe9b91dafb4cf but without a test case, because the test case depends on an n-gram tokenizer that will be missing from MariaDB until MDEV-10267 is added.
-rw-r--r--storage/innobase/fts/fts0que.cc31
1 files changed, 17 insertions, 14 deletions
diff --git a/storage/innobase/fts/fts0que.cc b/storage/innobase/fts/fts0que.cc
index be758c13d52..df2b330fe4b 100644
--- a/storage/innobase/fts/fts0que.cc
+++ b/storage/innobase/fts/fts0que.cc
@@ -4421,24 +4421,27 @@ fts_phrase_or_proximity_search(
if (k == ib_vector_size(query->match_array[j])) {
end_list = TRUE;
- if (match[j]->doc_id != match[0]->doc_id) {
- /* no match */
- if (query->flags & FTS_PHRASE) {
- ulint s;
+ if (query->flags & FTS_PHRASE) {
+ ulint s;
+ /* Since i is the last doc id in the
+ match_array[j], remove all doc ids > i
+ from the match_array[0]. */
+ fts_match_t* match_temp;
+ for (s = i + 1; s < n_matched; s++) {
+ match_temp = static_cast<
+ fts_match_t*>(ib_vector_get(
+ query->match_array[0], s));
+ match_temp->doc_id = 0;
+ }
+ if (match[j]->doc_id !=
+ match[0]->doc_id) {
+ /* no match */
match[0]->doc_id = 0;
-
- for (s = i + 1; s < n_matched;
- s++) {
- match[0] = static_cast<
- fts_match_t*>(
- ib_vector_get(
- query->match_array[0],
- s));
- match[0]->doc_id = 0;
- }
}
+ }
+ if (match[j]->doc_id != match[0]->doc_id) {
goto func_exit;
}
}