|
|
|
@ -1534,7 +1534,8 @@ fts_merge_doc_ids( |
|
|
|
{ |
|
|
|
const ib_rbt_node_t* node; |
|
|
|
|
|
|
|
ut_a(!rbt_empty(doc_ids)); |
|
|
|
DBUG_ENTER("fts_merge_doc_ids"); |
|
|
|
|
|
|
|
ut_a(!query->intersection); |
|
|
|
|
|
|
|
/* To process FTS_EXIST operation (intersection), we need
|
|
|
|
@ -1559,7 +1560,7 @@ fts_merge_doc_ids( |
|
|
|
query, ranking->doc_id, ranking->rank); |
|
|
|
|
|
|
|
if (query->error != DB_SUCCESS) { |
|
|
|
return(query->error); |
|
|
|
DBUG_RETURN(query->error); |
|
|
|
} |
|
|
|
|
|
|
|
/* Merge words. Don't need to take operator into account. */ |
|
|
|
@ -1578,7 +1579,7 @@ fts_merge_doc_ids( |
|
|
|
query->intersection = NULL; |
|
|
|
} |
|
|
|
|
|
|
|
return(DB_SUCCESS); |
|
|
|
DBUG_RETURN(DB_SUCCESS); |
|
|
|
} |
|
|
|
|
|
|
|
/*****************************************************************//**
|
|
|
|
@ -2838,11 +2839,11 @@ fts_query_visitor( |
|
|
|
fts_query_t* query = static_cast<fts_query_t*>(arg); |
|
|
|
|
|
|
|
ut_a(node); |
|
|
|
DBUG_ENTER("fts_query_visitor"); |
|
|
|
DBUG_PRINT("fts", ("nodetype: %s", fts_ast_node_type_get(node->type))); |
|
|
|
|
|
|
|
token.f_n_char = 0; |
|
|
|
|
|
|
|
query->oper = oper; |
|
|
|
|
|
|
|
query->cur_node = node; |
|
|
|
|
|
|
|
switch (node->type) { |
|
|
|
@ -2904,7 +2905,7 @@ fts_query_visitor( |
|
|
|
query->multi_exist = true; |
|
|
|
} |
|
|
|
|
|
|
|
return(query->error); |
|
|
|
DBUG_RETURN(query->error); |
|
|
|
} |
|
|
|
|
|
|
|
/*****************************************************************//**
|
|
|
|
@ -2928,6 +2929,8 @@ fts_ast_visit_sub_exp( |
|
|
|
bool will_be_ignored = false; |
|
|
|
bool multi_exist; |
|
|
|
|
|
|
|
DBUG_ENTER("fts_ast_visit_sub_exp"); |
|
|
|
|
|
|
|
ut_a(node->type == FTS_AST_SUBEXP_LIST); |
|
|
|
|
|
|
|
cur_oper = query->oper; |
|
|
|
@ -2956,14 +2959,14 @@ fts_ast_visit_sub_exp( |
|
|
|
/* Merge the sub-expression result with the parent result set. */ |
|
|
|
subexpr_doc_ids = query->doc_ids; |
|
|
|
query->doc_ids = parent_doc_ids; |
|
|
|
if (error == DB_SUCCESS && !rbt_empty(subexpr_doc_ids)) { |
|
|
|
if (error == DB_SUCCESS) { |
|
|
|
error = fts_merge_doc_ids(query, subexpr_doc_ids); |
|
|
|
} |
|
|
|
|
|
|
|
/* Free current result set. Result already merged into parent. */ |
|
|
|
fts_query_free_doc_ids(query, subexpr_doc_ids); |
|
|
|
|
|
|
|
return(error); |
|
|
|
DBUG_RETURN(error); |
|
|
|
} |
|
|
|
|
|
|
|
#if 0
|
|
|
|
@ -3439,8 +3442,10 @@ fts_retrieve_ranking( |
|
|
|
ib_rbt_bound_t parent; |
|
|
|
fts_ranking_t new_ranking; |
|
|
|
|
|
|
|
DBUG_ENTER("fts_retrieve_ranking"); |
|
|
|
|
|
|
|
if (!result || !result->rankings_by_id) { |
|
|
|
return(0); |
|
|
|
DBUG_RETURN(0); |
|
|
|
} |
|
|
|
|
|
|
|
new_ranking.doc_id = doc_id; |
|
|
|
@ -3451,10 +3456,10 @@ fts_retrieve_ranking( |
|
|
|
|
|
|
|
ranking = rbt_value(fts_ranking_t, parent.last); |
|
|
|
|
|
|
|
return(ranking->rank); |
|
|
|
DBUG_RETURN(ranking->rank); |
|
|
|
} |
|
|
|
|
|
|
|
return(0); |
|
|
|
DBUG_RETURN(0); |
|
|
|
} |
|
|
|
|
|
|
|
/*****************************************************************//**
|
|
|
|
@ -3471,6 +3476,8 @@ fts_query_prepare_result( |
|
|
|
const ib_rbt_node_t* node; |
|
|
|
bool result_is_null = false; |
|
|
|
|
|
|
|
DBUG_ENTER("fts_query_prepare_result"); |
|
|
|
|
|
|
|
if (result == NULL) { |
|
|
|
result = static_cast<fts_result_t*>(ut_malloc(sizeof(*result))); |
|
|
|
|
|
|
|
@ -3519,7 +3526,7 @@ fts_query_prepare_result( |
|
|
|
if (query->total_size > fts_result_cache_limit) { |
|
|
|
query->error = DB_FTS_EXCEED_RESULT_CACHE_LIMIT; |
|
|
|
fts_query_free_result(result); |
|
|
|
return(NULL); |
|
|
|
DBUG_RETURN(NULL); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -3542,7 +3549,7 @@ fts_query_prepare_result( |
|
|
|
ranking->rank * word_freq->idf * word_freq->idf); |
|
|
|
} |
|
|
|
|
|
|
|
return(result); |
|
|
|
DBUG_RETURN(result); |
|
|
|
} |
|
|
|
|
|
|
|
ut_a(rbt_size(query->doc_ids) > 0); |
|
|
|
@ -3569,7 +3576,7 @@ fts_query_prepare_result( |
|
|
|
if (query->total_size > fts_result_cache_limit) { |
|
|
|
query->error = DB_FTS_EXCEED_RESULT_CACHE_LIMIT; |
|
|
|
fts_query_free_result(result); |
|
|
|
return(NULL); |
|
|
|
DBUG_RETURN(NULL); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -3581,7 +3588,7 @@ fts_query_prepare_result( |
|
|
|
query->doc_ids = NULL; |
|
|
|
} |
|
|
|
|
|
|
|
return(result); |
|
|
|
DBUG_RETURN(result); |
|
|
|
} |
|
|
|
|
|
|
|
/*****************************************************************//**
|
|
|
|
@ -3593,6 +3600,8 @@ fts_query_get_result( |
|
|
|
fts_query_t* query, /*!< in: query instance */ |
|
|
|
fts_result_t* result) /*!< in: result */ |
|
|
|
{ |
|
|
|
DBUG_ENTER("fts_query_get_result"); |
|
|
|
|
|
|
|
if (rbt_size(query->doc_ids) > 0 || query->flags == FTS_OPT_RANKING) { |
|
|
|
/* Copy the doc ids to the result. */ |
|
|
|
result = fts_query_prepare_result(query, result); |
|
|
|
@ -3602,7 +3611,7 @@ fts_query_get_result( |
|
|
|
memset(result, 0, sizeof(*result)); |
|
|
|
} |
|
|
|
|
|
|
|
return(result); |
|
|
|
DBUG_RETURN(result); |
|
|
|
} |
|
|
|
|
|
|
|
/*****************************************************************//**
|
|
|
|
@ -3680,6 +3689,7 @@ fts_query_parse( |
|
|
|
int error; |
|
|
|
fts_ast_state_t state; |
|
|
|
bool mode = query->boolean_mode; |
|
|
|
DBUG_ENTER("fts_query_parse"); |
|
|
|
|
|
|
|
memset(&state, 0x0, sizeof(state)); |
|
|
|
|
|
|
|
@ -3698,7 +3708,7 @@ fts_query_parse( |
|
|
|
query->root = state.root; |
|
|
|
} |
|
|
|
|
|
|
|
return(state.root); |
|
|
|
DBUG_RETURN(state.root); |
|
|
|
} |
|
|
|
|
|
|
|
/*******************************************************************//**
|
|
|
|
|