Skip to content

Commit 3bc094d

Browse files
committed
Remove dead code for pushing down LIMIT to InnoDB FULLTEXT INDEX queries
MySQL 5.7 added code to push down the LIMIT to fulltext search in InnoDB: commit 2cd0ebf97e1b265e2282d7ceb5d8dfb663ffc48f Author: Thirunarayanan Balathandayuthapani <thirunarayanan.balathandayuth@oracle.com> Date: Fri May 27 13:49:28 2016 +0530 Bug #22709692 FTS QUERY EXCEEDS RESULT CACHE LIMIT The code was disabled when MySQL 5.7.9 was merged to MariaDB 10.2.2. We shall remove the disabled code and unnecessary variables.
1 parent a631022 commit 3bc094d

File tree

4 files changed

+4
-48
lines changed

4 files changed

+4
-48
lines changed

storage/innobase/fts/fts0que.cc

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,6 @@ struct fts_query_t {
149149
bool multi_exist; /*!< multiple FTS_EXIST oper */
150150

151151
st_mysql_ftparser* parser; /*!< fts plugin parser */
152-
153-
/** limit value for the fts query */
154-
ulonglong limit;
155-
156-
/** number of docs fetched by query. This is to restrict the
157-
result with limit value */
158-
ulonglong n_docs;
159152
};
160153

161154
/** For phrase matching, first we collect the documents and the positions
@@ -3228,11 +3221,6 @@ fts_query_filter_doc_ids(
32283221
ulint decoded = 0;
32293222
ib_rbt_t* doc_freqs = word_freq->doc_freqs;
32303223

3231-
if (query->limit != ULONG_UNDEFINED
3232-
&& query->n_docs >= query->limit) {
3233-
return(DB_SUCCESS);
3234-
}
3235-
32363224
/* Decode the ilist and add the doc ids to the query doc_id set. */
32373225
while (decoded < len) {
32383226
ulint freq = 0;
@@ -3320,17 +3308,11 @@ fts_query_filter_doc_ids(
33203308
/* Add the word to the document's matched RB tree. */
33213309
fts_query_add_word_to_document(query, doc_id, word);
33223310
}
3323-
3324-
if (query->limit != ULONG_UNDEFINED
3325-
&& query->limit <= ++query->n_docs) {
3326-
goto func_exit;
3327-
}
33283311
}
33293312

33303313
/* Some sanity checks. */
33313314
ut_a(doc_id == node->last_doc_id);
33323315

3333-
func_exit:
33343316
if (query->total_size > fts_result_cache_limit) {
33353317
return(DB_FTS_EXCEED_RESULT_CACHE_LIMIT);
33363318
} else {
@@ -3941,7 +3923,6 @@ fts_query_can_optimize(
39413923
@param[in] query_str FTS query
39423924
@param[in] query_len FTS query string len in bytes
39433925
@param[in,out] result result doc ids
3944-
@param[in] limit limit value
39453926
@return DB_SUCCESS if successful otherwise error code */
39463927
dberr_t
39473928
fts_query(
@@ -3950,8 +3931,7 @@ fts_query(
39503931
uint flags,
39513932
const byte* query_str,
39523933
ulint query_len,
3953-
fts_result_t** result,
3954-
ulonglong limit)
3934+
fts_result_t** result)
39553935
{
39563936
fts_query_t query;
39573937
dberr_t error = DB_SUCCESS;
@@ -4013,10 +3993,6 @@ fts_query(
40133993

40143994
query.total_docs = dict_table_get_n_rows(index->table);
40153995

4016-
query.limit = limit;
4017-
4018-
query.n_docs = 0;
4019-
40203996
query.fts_common_table.suffix = "DELETED";
40213997

40223998
/* Read the deleted doc_ids, we need these for filtering. */
@@ -4078,19 +4054,6 @@ fts_query(
40784054
fts_result_cache_limit = 2048;
40794055
);
40804056

4081-
/* Optimisation is allowed for limit value
4082-
when
4083-
i) No ranking involved
4084-
ii) Only FTS Union operations involved. */
4085-
if (query.limit != ULONG_UNDEFINED
4086-
&& !fts_ast_node_check_union(ast)) {
4087-
query.limit = ULONG_UNDEFINED;
4088-
}
4089-
4090-
DBUG_EXECUTE_IF("fts_union_limit_off",
4091-
query.limit = ULONG_UNDEFINED;
4092-
);
4093-
40944057
/* Traverse the Abstract Syntax Tree (AST) and execute
40954058
the query. */
40964059
query.error = fts_ast_visit(

storage/innobase/handler/ha_innodb.cc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10537,10 +10537,8 @@ ha_innobase::ft_init_ext(
1053710537
const byte* q = reinterpret_cast<const byte*>(
1053810538
const_cast<char*>(query));
1053910539

10540-
// JAN: TODO: support for ft_init_ext_with_hints(), remove the line below
10541-
m_prebuilt->m_fts_limit= ULONG_UNDEFINED;
10542-
dberr_t error = fts_query(trx, index, flags, q, query_len, &result,
10543-
m_prebuilt->m_fts_limit);
10540+
// FIXME: support ft_init_ext_with_hints(), pass LIMIT
10541+
dberr_t error = fts_query(trx, index, flags, q, query_len, &result);
1054410542

1054510543
if (error != DB_SUCCESS) {
1054610544
my_error(convert_error_code_to_mysql(error, 0, NULL), MYF(0));

storage/innobase/include/fts0fts.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,6 @@ fts_commit(
579579
@param[in] query_str FTS query
580580
@param[in] query_len FTS query string len in bytes
581581
@param[in,out] result result doc ids
582-
@param[in] limit limit value
583582
@return DB_SUCCESS if successful otherwise error code */
584583
dberr_t
585584
fts_query(
@@ -588,8 +587,7 @@ fts_query(
588587
uint flags,
589588
const byte* query_str,
590589
ulint query_len,
591-
fts_result_t** result,
592-
ulonglong limit)
590+
fts_result_t** result)
593591
MY_ATTRIBUTE((warn_unused_result));
594592

595593
/******************************************************************//**

storage/innobase/include/row0mysql.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -844,9 +844,6 @@ struct row_prebuilt_t {
844844

845845
/** The MySQL table object */
846846
TABLE* m_mysql_table;
847-
848-
/** limit value to avoid fts result overflow */
849-
ulonglong m_fts_limit;
850847
};
851848

852849
/** Callback for row_mysql_sys_index_iterate() */

0 commit comments

Comments
 (0)