Skip to content

Commit e391417

Browse files
sachinagarwal1111dr-m
authored andcommitted
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.
1 parent 784473b commit e391417

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

storage/innobase/fts/fts0que.cc

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4421,24 +4421,27 @@ fts_phrase_or_proximity_search(
44214421
if (k == ib_vector_size(query->match_array[j])) {
44224422
end_list = TRUE;
44234423

4424-
if (match[j]->doc_id != match[0]->doc_id) {
4425-
/* no match */
4426-
if (query->flags & FTS_PHRASE) {
4427-
ulint s;
4424+
if (query->flags & FTS_PHRASE) {
4425+
ulint s;
4426+
/* Since i is the last doc id in the
4427+
match_array[j], remove all doc ids > i
4428+
from the match_array[0]. */
4429+
fts_match_t* match_temp;
4430+
for (s = i + 1; s < n_matched; s++) {
4431+
match_temp = static_cast<
4432+
fts_match_t*>(ib_vector_get(
4433+
query->match_array[0], s));
4434+
match_temp->doc_id = 0;
4435+
}
44284436

4437+
if (match[j]->doc_id !=
4438+
match[0]->doc_id) {
4439+
/* no match */
44294440
match[0]->doc_id = 0;
4430-
4431-
for (s = i + 1; s < n_matched;
4432-
s++) {
4433-
match[0] = static_cast<
4434-
fts_match_t*>(
4435-
ib_vector_get(
4436-
query->match_array[0],
4437-
s));
4438-
match[0]->doc_id = 0;
4439-
}
44404441
}
4442+
}
44414443

4444+
if (match[j]->doc_id != match[0]->doc_id) {
44424445
goto func_exit;
44434446
}
44444447
}

0 commit comments

Comments
 (0)