Commit 3bc094d3 authored by Marko Mäkelä's avatar Marko Mäkelä

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.
parent a6310222
...@@ -149,13 +149,6 @@ struct fts_query_t { ...@@ -149,13 +149,6 @@ struct fts_query_t {
bool multi_exist; /*!< multiple FTS_EXIST oper */ bool multi_exist; /*!< multiple FTS_EXIST oper */
st_mysql_ftparser* parser; /*!< fts plugin parser */ st_mysql_ftparser* parser; /*!< fts plugin parser */
/** limit value for the fts query */
ulonglong limit;
/** number of docs fetched by query. This is to restrict the
result with limit value */
ulonglong n_docs;
}; };
/** For phrase matching, first we collect the documents and the positions /** For phrase matching, first we collect the documents and the positions
...@@ -3228,11 +3221,6 @@ fts_query_filter_doc_ids( ...@@ -3228,11 +3221,6 @@ fts_query_filter_doc_ids(
ulint decoded = 0; ulint decoded = 0;
ib_rbt_t* doc_freqs = word_freq->doc_freqs; ib_rbt_t* doc_freqs = word_freq->doc_freqs;
if (query->limit != ULONG_UNDEFINED
&& query->n_docs >= query->limit) {
return(DB_SUCCESS);
}
/* Decode the ilist and add the doc ids to the query doc_id set. */ /* Decode the ilist and add the doc ids to the query doc_id set. */
while (decoded < len) { while (decoded < len) {
ulint freq = 0; ulint freq = 0;
...@@ -3320,17 +3308,11 @@ fts_query_filter_doc_ids( ...@@ -3320,17 +3308,11 @@ fts_query_filter_doc_ids(
/* Add the word to the document's matched RB tree. */ /* Add the word to the document's matched RB tree. */
fts_query_add_word_to_document(query, doc_id, word); fts_query_add_word_to_document(query, doc_id, word);
} }
if (query->limit != ULONG_UNDEFINED
&& query->limit <= ++query->n_docs) {
goto func_exit;
}
} }
/* Some sanity checks. */ /* Some sanity checks. */
ut_a(doc_id == node->last_doc_id); ut_a(doc_id == node->last_doc_id);
func_exit:
if (query->total_size > fts_result_cache_limit) { if (query->total_size > fts_result_cache_limit) {
return(DB_FTS_EXCEED_RESULT_CACHE_LIMIT); return(DB_FTS_EXCEED_RESULT_CACHE_LIMIT);
} else { } else {
...@@ -3941,7 +3923,6 @@ fts_query_can_optimize( ...@@ -3941,7 +3923,6 @@ fts_query_can_optimize(
@param[in] query_str FTS query @param[in] query_str FTS query
@param[in] query_len FTS query string len in bytes @param[in] query_len FTS query string len in bytes
@param[in,out] result result doc ids @param[in,out] result result doc ids
@param[in] limit limit value
@return DB_SUCCESS if successful otherwise error code */ @return DB_SUCCESS if successful otherwise error code */
dberr_t dberr_t
fts_query( fts_query(
...@@ -3950,8 +3931,7 @@ fts_query( ...@@ -3950,8 +3931,7 @@ fts_query(
uint flags, uint flags,
const byte* query_str, const byte* query_str,
ulint query_len, ulint query_len,
fts_result_t** result, fts_result_t** result)
ulonglong limit)
{ {
fts_query_t query; fts_query_t query;
dberr_t error = DB_SUCCESS; dberr_t error = DB_SUCCESS;
...@@ -4013,10 +3993,6 @@ fts_query( ...@@ -4013,10 +3993,6 @@ fts_query(
query.total_docs = dict_table_get_n_rows(index->table); query.total_docs = dict_table_get_n_rows(index->table);
query.limit = limit;
query.n_docs = 0;
query.fts_common_table.suffix = "DELETED"; query.fts_common_table.suffix = "DELETED";
/* Read the deleted doc_ids, we need these for filtering. */ /* Read the deleted doc_ids, we need these for filtering. */
...@@ -4078,19 +4054,6 @@ fts_query( ...@@ -4078,19 +4054,6 @@ fts_query(
fts_result_cache_limit = 2048; fts_result_cache_limit = 2048;
); );
/* Optimisation is allowed for limit value
when
i) No ranking involved
ii) Only FTS Union operations involved. */
if (query.limit != ULONG_UNDEFINED
&& !fts_ast_node_check_union(ast)) {
query.limit = ULONG_UNDEFINED;
}
DBUG_EXECUTE_IF("fts_union_limit_off",
query.limit = ULONG_UNDEFINED;
);
/* Traverse the Abstract Syntax Tree (AST) and execute /* Traverse the Abstract Syntax Tree (AST) and execute
the query. */ the query. */
query.error = fts_ast_visit( query.error = fts_ast_visit(
......
...@@ -10537,10 +10537,8 @@ ha_innobase::ft_init_ext( ...@@ -10537,10 +10537,8 @@ ha_innobase::ft_init_ext(
const byte* q = reinterpret_cast<const byte*>( const byte* q = reinterpret_cast<const byte*>(
const_cast<char*>(query)); const_cast<char*>(query));
// JAN: TODO: support for ft_init_ext_with_hints(), remove the line below // FIXME: support ft_init_ext_with_hints(), pass LIMIT
m_prebuilt->m_fts_limit= ULONG_UNDEFINED; dberr_t error = fts_query(trx, index, flags, q, query_len, &result);
dberr_t error = fts_query(trx, index, flags, q, query_len, &result,
m_prebuilt->m_fts_limit);
if (error != DB_SUCCESS) { if (error != DB_SUCCESS) {
my_error(convert_error_code_to_mysql(error, 0, NULL), MYF(0)); my_error(convert_error_code_to_mysql(error, 0, NULL), MYF(0));
......
...@@ -579,7 +579,6 @@ fts_commit( ...@@ -579,7 +579,6 @@ fts_commit(
@param[in] query_str FTS query @param[in] query_str FTS query
@param[in] query_len FTS query string len in bytes @param[in] query_len FTS query string len in bytes
@param[in,out] result result doc ids @param[in,out] result result doc ids
@param[in] limit limit value
@return DB_SUCCESS if successful otherwise error code */ @return DB_SUCCESS if successful otherwise error code */
dberr_t dberr_t
fts_query( fts_query(
...@@ -588,8 +587,7 @@ fts_query( ...@@ -588,8 +587,7 @@ fts_query(
uint flags, uint flags,
const byte* query_str, const byte* query_str,
ulint query_len, ulint query_len,
fts_result_t** result, fts_result_t** result)
ulonglong limit)
MY_ATTRIBUTE((warn_unused_result)); MY_ATTRIBUTE((warn_unused_result));
/******************************************************************//** /******************************************************************//**
......
...@@ -844,9 +844,6 @@ struct row_prebuilt_t { ...@@ -844,9 +844,6 @@ struct row_prebuilt_t {
/** The MySQL table object */ /** The MySQL table object */
TABLE* m_mysql_table; TABLE* m_mysql_table;
/** limit value to avoid fts result overflow */
ulonglong m_fts_limit;
}; };
/** Callback for row_mysql_sys_index_iterate() */ /** Callback for row_mysql_sys_index_iterate() */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment