Skip to content

Commit

Permalink
Remove dead code for pushing down LIMIT to InnoDB FULLTEXT INDEX queries
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dr-m committed Oct 18, 2017
1 parent a631022 commit 3bc094d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 48 deletions.
39 changes: 1 addition & 38 deletions storage/innobase/fts/fts0que.cc
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,6 @@ struct fts_query_t {
bool multi_exist; /*!< multiple FTS_EXIST oper */

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
Expand Down Expand Up @@ -3228,11 +3221,6 @@ fts_query_filter_doc_ids(
ulint decoded = 0;
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. */
while (decoded < len) {
ulint freq = 0;
Expand Down Expand Up @@ -3320,17 +3308,11 @@ fts_query_filter_doc_ids(
/* Add the word to the document's matched RB tree. */
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. */
ut_a(doc_id == node->last_doc_id);

func_exit:
if (query->total_size > fts_result_cache_limit) {
return(DB_FTS_EXCEED_RESULT_CACHE_LIMIT);
} else {
Expand Down Expand Up @@ -3941,7 +3923,6 @@ fts_query_can_optimize(
@param[in] query_str FTS query
@param[in] query_len FTS query string len in bytes
@param[in,out] result result doc ids
@param[in] limit limit value
@return DB_SUCCESS if successful otherwise error code */
dberr_t
fts_query(
Expand All @@ -3950,8 +3931,7 @@ fts_query(
uint flags,
const byte* query_str,
ulint query_len,
fts_result_t** result,
ulonglong limit)
fts_result_t** result)
{
fts_query_t query;
dberr_t error = DB_SUCCESS;
Expand Down Expand Up @@ -4013,10 +3993,6 @@ fts_query(

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

query.limit = limit;

query.n_docs = 0;

query.fts_common_table.suffix = "DELETED";

/* Read the deleted doc_ids, we need these for filtering. */
Expand Down Expand Up @@ -4078,19 +4054,6 @@ fts_query(
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
the query. */
query.error = fts_ast_visit(
Expand Down
6 changes: 2 additions & 4 deletions storage/innobase/handler/ha_innodb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10537,10 +10537,8 @@ ha_innobase::ft_init_ext(
const byte* q = reinterpret_cast<const byte*>(
const_cast<char*>(query));

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

if (error != DB_SUCCESS) {
my_error(convert_error_code_to_mysql(error, 0, NULL), MYF(0));
Expand Down
4 changes: 1 addition & 3 deletions storage/innobase/include/fts0fts.h
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,6 @@ fts_commit(
@param[in] query_str FTS query
@param[in] query_len FTS query string len in bytes
@param[in,out] result result doc ids
@param[in] limit limit value
@return DB_SUCCESS if successful otherwise error code */
dberr_t
fts_query(
Expand All @@ -588,8 +587,7 @@ fts_query(
uint flags,
const byte* query_str,
ulint query_len,
fts_result_t** result,
ulonglong limit)
fts_result_t** result)
MY_ATTRIBUTE((warn_unused_result));

/******************************************************************//**
Expand Down
3 changes: 0 additions & 3 deletions storage/innobase/include/row0mysql.h
Original file line number Diff line number Diff line change
Expand Up @@ -844,9 +844,6 @@ struct row_prebuilt_t {

/** The MySQL table object */
TABLE* m_mysql_table;

/** limit value to avoid fts result overflow */
ulonglong m_fts_limit;
};

/** Callback for row_mysql_sys_index_iterate() */
Expand Down

0 comments on commit 3bc094d

Please sign in to comment.