summaryrefslogtreecommitdiff
path: root/storage/innobase/include/fts0priv.h
diff options
context:
space:
mode:
Diffstat (limited to 'storage/innobase/include/fts0priv.h')
-rw-r--r--storage/innobase/include/fts0priv.h163
1 files changed, 78 insertions, 85 deletions
diff --git a/storage/innobase/include/fts0priv.h b/storage/innobase/include/fts0priv.h
index 2d4e9d88fd1..f7a2d2c72f2 100644
--- a/storage/innobase/include/fts0priv.h
+++ b/storage/innobase/include/fts0priv.h
@@ -26,6 +26,7 @@ Created 2011/09/02 Sunny Bains
#ifndef INNOBASE_FTS0PRIV_H
#define INNOBASE_FTS0PRIV_H
+#include "univ.i"
#include "dict0dict.h"
#include "pars0pars.h"
#include "que0que.h"
@@ -114,7 +115,6 @@ component.
/******************************************************************//**
Parse an SQL string. %s is replaced with the table's id.
@return query graph */
-UNIV_INTERN
que_t*
fts_parse_sql(
/*==========*/
@@ -122,26 +122,27 @@ fts_parse_sql(
pars_info_t* info, /*!< in: info struct, or NULL */
const char* sql) /*!< in: SQL string to evaluate */
MY_ATTRIBUTE((nonnull(3), malloc, warn_unused_result));
+
/******************************************************************//**
Evaluate a parsed SQL statement
@return DB_SUCCESS or error code */
-UNIV_INTERN
dberr_t
fts_eval_sql(
/*=========*/
trx_t* trx, /*!< in: transaction */
que_t* graph) /*!< in: Parsed statement */
MY_ATTRIBUTE((nonnull, warn_unused_result));
+
/******************************************************************//**
Construct the name of an ancillary FTS table for the given table.
-@return own: table name, must be freed with mem_free() */
-UNIV_INTERN
-char*
+Caller must allocate enough memory(usually size of MAX_FULL_NAME_LEN)
+for param 'table_name'. */
+void
fts_get_table_name(
/*===============*/
- const fts_table_t*
- fts_table) /*!< in: FTS aux table info */
- MY_ATTRIBUTE((nonnull, malloc, warn_unused_result));
+ const fts_table_t* fts_table, /*!< in: FTS aux table info */
+ char* table_name); /*!< in/out: aux table name */
+
/******************************************************************//**
Construct the column specification part of the SQL string for selecting the
indexed FTS columns for the given table. Adds the necessary bound
@@ -157,7 +158,6 @@ Two indexed columns named "subject" and "content":
"$sel0, $sel1",
info/ids: sel0 -> "subject", sel1 -> "content",
@return heap-allocated WHERE string */
-UNIV_INTERN
const char*
fts_get_select_columns_str(
/*=======================*/
@@ -177,7 +177,6 @@ ID */
Fetch document (= a single row's indexed text) with the given
document id.
@return: DB_SUCCESS if fetch is successful, else error */
-UNIV_INTERN
dberr_t
fts_doc_fetch_by_doc_id(
/*====================*/
@@ -197,7 +196,6 @@ fts_doc_fetch_by_doc_id(
Callback function for fetch that stores the text of an FTS document,
converting each column to UTF-16.
@return always FALSE */
-UNIV_INTERN
ibool
fts_query_expansion_fetch_doc(
/*==========================*/
@@ -207,7 +205,6 @@ fts_query_expansion_fetch_doc(
/********************************************************************
Write out a single word's data as new entry/entries in the INDEX table.
@return DB_SUCCESS if all OK. */
-UNIV_INTERN
dberr_t
fts_write_node(
/*===========*/
@@ -217,21 +214,37 @@ fts_write_node(
fts_string_t* word, /*!< in: word in UTF-8 */
fts_node_t* node) /*!< in: node columns */
MY_ATTRIBUTE((nonnull, warn_unused_result));
+
+/** Check fts token
+1. for ngram token, check whether the token contains any words in stopwords
+2. for non-ngram token, check if it's stopword or less than fts_min_token_size
+or greater than fts_max_token_size.
+@param[in] token token string
+@param[in] stopwords stopwords rb tree
+@param[in] is_ngram is ngram parser
+@param[in] cs token charset
+@retval true if it is not stopword and length in range
+@retval false if it is stopword or length not in range */
+bool
+fts_check_token(
+ const fts_string_t* token,
+ const ib_rbt_t* stopwords,
+ bool is_ngram,
+ const CHARSET_INFO* cs);
+
/*******************************************************************//**
Tokenize a document. */
-UNIV_INTERN
void
fts_tokenize_document(
/*==================*/
fts_doc_t* doc, /*!< in/out: document to
tokenize */
- fts_doc_t* result) /*!< out: if provided, save
+ fts_doc_t* result, /*!< out: if provided, save
result tokens here */
- MY_ATTRIBUTE((nonnull(1)));
+ st_mysql_ftparser* parser);/* in: plugin fts parser */
/*******************************************************************//**
Continue to tokenize a document. */
-UNIV_INTERN
void
fts_tokenize_document_next(
/*=======================*/
@@ -239,23 +252,21 @@ fts_tokenize_document_next(
tokenize */
ulint add_pos, /*!< in: add this position to all
tokens from this tokenization */
- fts_doc_t* result) /*!< out: if provided, save
+ fts_doc_t* result, /*!< out: if provided, save
result tokens here */
- MY_ATTRIBUTE((nonnull(1)));
+ st_mysql_ftparser* parser);/* in: plugin fts parser */
+
/******************************************************************//**
Initialize a document. */
-UNIV_INTERN
void
fts_doc_init(
/*=========*/
- fts_doc_t* doc) /*!< in: doc to initialize */
- MY_ATTRIBUTE((nonnull));
+ fts_doc_t* doc); /*!< in: doc to initialize */
/******************************************************************//**
Do a binary search for a doc id in the array
@return +ve index if found -ve index where it should be
inserted if not found */
-UNIV_INTERN
int
fts_bsearch(
/*========*/
@@ -266,24 +277,21 @@ fts_bsearch(
MY_ATTRIBUTE((nonnull, warn_unused_result));
/******************************************************************//**
Free document. */
-UNIV_INTERN
void
fts_doc_free(
/*=========*/
- fts_doc_t* doc) /*!< in: document */
- MY_ATTRIBUTE((nonnull));
+ fts_doc_t* doc); /*!< in: document */
+
/******************************************************************//**
Free fts_optimizer_word_t instanace.*/
-UNIV_INTERN
void
fts_word_free(
/*==========*/
- fts_word_t* word) /*!< in: instance to free.*/
- MY_ATTRIBUTE((nonnull));
+ fts_word_t* word); /*!< in: instance to free.*/
+
/******************************************************************//**
Read the rows from the FTS inde
@return DB_SUCCESS or error code */
-UNIV_INTERN
dberr_t
fts_index_fetch_nodes(
/*==================*/
@@ -292,19 +300,18 @@ fts_index_fetch_nodes(
fts_table_t* fts_table, /*!< in: FTS aux table */
const fts_string_t*
word, /*!< in: the word to fetch */
- fts_fetch_t* fetch) /*!< in: fetch callback.*/
- MY_ATTRIBUTE((nonnull));
+ fts_fetch_t* fetch); /*!< in: fetch callback.*/
+
/******************************************************************//**
Create a fts_optimizer_word_t instance.
@return new instance */
-UNIV_INTERN
fts_word_t*
fts_word_init(
/*==========*/
fts_word_t* word, /*!< in: word to initialize */
byte* utf8, /*!< in: UTF-8 string */
- ulint len) /*!< in: length of string in bytes */
- MY_ATTRIBUTE((nonnull));
+ ulint len); /*!< in: length of string in bytes */
+
/******************************************************************//**
Compare two fts_trx_table_t instances, we actually compare the
table id's here.
@@ -314,8 +321,8 @@ int
fts_trx_table_cmp(
/*==============*/
const void* v1, /*!< in: id1 */
- const void* v2) /*!< in: id2 */
- MY_ATTRIBUTE((nonnull, warn_unused_result));
+ const void* v2); /*!< in: id2 */
+
/******************************************************************//**
Compare a table id with a trx_table_t table id.
@return < 0 if n1 < n2, 0 if n1 == n2, > 0 if n1 > n2 */
@@ -324,31 +331,28 @@ int
fts_trx_table_id_cmp(
/*=================*/
const void* p1, /*!< in: id1 */
- const void* p2) /*!< in: id2 */
- MY_ATTRIBUTE((nonnull, warn_unused_result));
+ const void* p2); /*!< in: id2 */
+
/******************************************************************//**
Commit a transaction.
@return DB_SUCCESS if all OK */
-UNIV_INTERN
dberr_t
fts_sql_commit(
/*===========*/
- trx_t* trx) /*!< in: transaction */
- MY_ATTRIBUTE((nonnull));
+ trx_t* trx); /*!< in: transaction */
+
/******************************************************************//**
Rollback a transaction.
@return DB_SUCCESS if all OK */
-UNIV_INTERN
dberr_t
fts_sql_rollback(
/*=============*/
- trx_t* trx) /*!< in: transaction */
- MY_ATTRIBUTE((nonnull));
+ trx_t* trx); /*!< in: transaction */
+
/******************************************************************//**
Parse an SQL string. %s is replaced with the table's id. Don't acquire
the dict mutex
@return query graph */
-UNIV_INTERN
que_t*
fts_parse_sql_no_dict_lock(
/*=======================*/
@@ -356,11 +360,11 @@ fts_parse_sql_no_dict_lock(
pars_info_t* info, /*!< in: parser info */
const char* sql) /*!< in: SQL string to evaluate */
MY_ATTRIBUTE((nonnull(3), malloc, warn_unused_result));
+
/******************************************************************//**
Get value from config table. The caller must ensure that enough
space is allocated for value to hold the column contents
@return DB_SUCCESS or error code */
-UNIV_INTERN
dberr_t
fts_config_get_value(
/*=================*/
@@ -368,15 +372,13 @@ fts_config_get_value(
fts_table_t* fts_table, /*!< in: the indexed FTS table */
const char* name, /*!< in: get config value for
this parameter name */
- fts_string_t* value) /*!< out: value read from
+ fts_string_t* value); /*!< out: value read from
config table */
- MY_ATTRIBUTE((nonnull));
/******************************************************************//**
Get value specific to an FTS index from the config table. The caller
must ensure that enough space is allocated for value to hold the
column contents.
@return DB_SUCCESS or error code */
-UNIV_INTERN
dberr_t
fts_config_get_index_value(
/*=======================*/
@@ -387,10 +389,10 @@ fts_config_get_index_value(
fts_string_t* value) /*!< out: value read from
config table */
MY_ATTRIBUTE((nonnull, warn_unused_result));
+
/******************************************************************//**
Set the value in the config table for name.
@return DB_SUCCESS or error code */
-UNIV_INTERN
dberr_t
fts_config_set_value(
/*=================*/
@@ -399,12 +401,11 @@ fts_config_set_value(
const char* name, /*!< in: get config value for
this parameter name */
const fts_string_t*
- value) /*!< in: value to update */
- MY_ATTRIBUTE((nonnull));
+ value); /*!< in: value to update */
+
/****************************************************************//**
Set an ulint value in the config table.
@return DB_SUCCESS if all OK else error code */
-UNIV_INTERN
dberr_t
fts_config_set_ulint(
/*=================*/
@@ -413,10 +414,10 @@ fts_config_set_ulint(
const char* name, /*!< in: param name */
ulint int_value) /*!< in: value */
MY_ATTRIBUTE((nonnull, warn_unused_result));
+
/******************************************************************//**
Set the value specific to an FTS index in the config table.
@return DB_SUCCESS or error code */
-UNIV_INTERN
dberr_t
fts_config_set_index_value(
/*=======================*/
@@ -427,10 +428,10 @@ fts_config_set_index_value(
fts_string_t* value) /*!< out: value read from
config table */
MY_ATTRIBUTE((nonnull, warn_unused_result));
+
/******************************************************************//**
Increment the value in the config table for column name.
@return DB_SUCCESS or error code */
-UNIV_INTERN
dberr_t
fts_config_increment_value(
/*=======================*/
@@ -440,10 +441,10 @@ fts_config_increment_value(
for this parameter name */
ulint delta) /*!< in: increment by this much */
MY_ATTRIBUTE((nonnull, warn_unused_result));
+
/******************************************************************//**
Increment the per index value in the config table for column name.
@return DB_SUCCESS or error code */
-UNIV_INTERN
dberr_t
fts_config_increment_index_value(
/*=============================*/
@@ -451,12 +452,11 @@ fts_config_increment_index_value(
dict_index_t* index, /*!< in: FTS index */
const char* name, /*!< in: increment config value
for this parameter name */
- ulint delta) /*!< in: increment by this much */
- MY_ATTRIBUTE((nonnull));
+ ulint delta); /*!< in: increment by this much */
+
/******************************************************************//**
Get an ulint value from the config table.
@return DB_SUCCESS or error code */
-UNIV_INTERN
dberr_t
fts_config_get_index_ulint(
/*=======================*/
@@ -465,10 +465,10 @@ fts_config_get_index_ulint(
const char* name, /*!< in: param name */
ulint* int_value) /*!< out: value */
MY_ATTRIBUTE((nonnull, warn_unused_result));
+
/******************************************************************//**
Set an ulint value int the config table.
@return DB_SUCCESS or error code */
-UNIV_INTERN
dberr_t
fts_config_set_index_ulint(
/*=======================*/
@@ -477,22 +477,21 @@ fts_config_set_index_ulint(
const char* name, /*!< in: param name */
ulint int_value) /*!< in: value */
MY_ATTRIBUTE((nonnull, warn_unused_result));
+
/******************************************************************//**
Get an ulint value from the config table.
@return DB_SUCCESS or error code */
-UNIV_INTERN
dberr_t
fts_config_get_ulint(
/*=================*/
trx_t* trx, /*!< in: transaction */
fts_table_t* fts_table, /*!< in: the indexed FTS table */
const char* name, /*!< in: param name */
- ulint* int_value) /*!< out: value */
- MY_ATTRIBUTE((nonnull));
+ ulint* int_value); /*!< out: value */
+
/******************************************************************//**
Search cache for word.
@return the word node vector if found else NULL */
-UNIV_INTERN
const ib_vector_t*
fts_cache_find_word(
/*================*/
@@ -501,10 +500,10 @@ fts_cache_find_word(
const fts_string_t*
text) /*!< in: word to search for */
MY_ATTRIBUTE((nonnull, warn_unused_result));
+
/******************************************************************//**
Check cache for deleted doc id.
@return TRUE if deleted */
-UNIV_INTERN
ibool
fts_cache_is_deleted_doc_id(
/*========================*/
@@ -512,9 +511,9 @@ fts_cache_is_deleted_doc_id(
cache, /*!< in: cache ito search */
doc_id_t doc_id) /*!< in: doc id to search for */
MY_ATTRIBUTE((nonnull, warn_unused_result));
+
/******************************************************************//**
Append deleted doc ids to vector and sort the vector. */
-UNIV_INTERN
void
fts_cache_append_deleted_doc_ids(
/*=============================*/
@@ -526,7 +525,6 @@ Wait for the background thread to start. We poll to detect change
of state, which is acceptable, since the wait should happen only
once during startup.
@return true if the thread started else FALSE (i.e timed out) */
-UNIV_INTERN
ibool
fts_wait_for_background_thread_to_start(
/*====================================*/
@@ -539,7 +537,6 @@ fts_wait_for_background_thread_to_start(
/******************************************************************//**
Get the total number of words in the FTS for a particular FTS index.
@return DB_SUCCESS or error code */
-UNIV_INTERN
dberr_t
fts_get_total_word_count(
/*=====================*/
@@ -551,7 +548,6 @@ fts_get_total_word_count(
/******************************************************************//**
Search the index specific cache for a particular FTS index.
@return the index specific cache else NULL */
-UNIV_INTERN
fts_index_cache_t*
fts_find_index_cache(
/*================*/
@@ -560,10 +556,11 @@ fts_find_index_cache(
const dict_index_t*
index) /*!< in: index to search for */
MY_ATTRIBUTE((nonnull, warn_unused_result));
+
/******************************************************************//**
Write the table id to the given buffer (including final NUL). Buffer must be
at least FTS_AUX_MIN_TABLE_ID_LENGTH bytes long.
-@return number of bytes written */
+@return number of bytes written */
UNIV_INLINE
int
fts_write_object_id(
@@ -584,10 +581,10 @@ fts_read_object_id(
ib_id_t* id, /*!< out: a table id */
const char* str) /*!< in: buffer to read from */
MY_ATTRIBUTE((nonnull, warn_unused_result));
+
/******************************************************************//**
Get the table id.
@return number of bytes written */
-UNIV_INTERN
int
fts_get_table_id(
/*=============*/
@@ -597,53 +594,49 @@ fts_get_table_id(
FTS_AUX_MIN_TABLE_ID_LENGTH bytes
long */
MY_ATTRIBUTE((nonnull, warn_unused_result));
+
/******************************************************************//**
Add the table to add to the OPTIMIZER's list. */
-UNIV_INTERN
void
fts_optimize_add_table(
/*===================*/
- dict_table_t* table) /*!< in: table to add */
- MY_ATTRIBUTE((nonnull));
+ dict_table_t* table); /*!< in: table to add */
+
/******************************************************************//**
Optimize a table. */
-UNIV_INTERN
void
fts_optimize_do_table(
/*==================*/
- dict_table_t* table) /*!< in: table to optimize */
- MY_ATTRIBUTE((nonnull));
+ dict_table_t* table); /*!< in: table to optimize */
+
/******************************************************************//**
Construct the prefix name of an FTS table.
-@return own: table name, must be freed with mem_free() */
-UNIV_INTERN
+@return own: table name, must be freed with ut_free() */
char*
fts_get_table_name_prefix(
/*======================*/
const fts_table_t*
fts_table) /*!< in: Auxiliary table type */
MY_ATTRIBUTE((nonnull, malloc, warn_unused_result));
+
/******************************************************************//**
Add node positions. */
-UNIV_INTERN
void
fts_cache_node_add_positions(
/*=========================*/
fts_cache_t* cache, /*!< in: cache */
fts_node_t* node, /*!< in: word node */
doc_id_t doc_id, /*!< in: doc id */
- ib_vector_t* positions) /*!< in: fts_token_t::positions */
- MY_ATTRIBUTE((nonnull(2,4)));
+ ib_vector_t* positions); /*!< in: fts_token_t::positions */
/******************************************************************//**
Create the config table name for retrieving index specific value.
@return index config parameter name */
-UNIV_INTERN
char*
fts_config_create_index_param_name(
/*===============================*/
- const char* param, /*!< in: base name of param */
- const dict_index_t* index) /*!< in: index for config */
+ const char* param, /*!< in: base name of param */
+ const dict_index_t* index) /*!< in: index for config */
MY_ATTRIBUTE((nonnull, malloc, warn_unused_result));
#ifndef UNIV_NONINL