Skip to content
Permalink
Browse files
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@5aa0752
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.
  • Loading branch information
sachinagarwal1111 authored and dr-m committed Oct 26, 2020
1 parent 784473b commit e391417
Showing 1 changed file with 17 additions and 14 deletions.
@@ -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;
}
}

0 comments on commit e391417

Please sign in to comment.