MySQL 8.0.39
Source Code Documentation
|
Full text search internal header file. More...
#include "dict0dict.h"
#include "fts0types.h"
#include "pars0pars.h"
#include "que0que.h"
#include "que0types.h"
#include "univ.i"
#include "fts0priv.ic"
Go to the source code of this file.
Macros | |
#define | FTS_BACKGROUND_THREAD_WAIT_COUNT 1000 |
Maximum number of iterations to wait before we complain. More... | |
#define | FTS_MAX_CONFIG_NAME_LEN 64 |
The maximum length of the config table's value column in bytes. More... | |
#define | FTS_MAX_CONFIG_VALUE_LEN 1024 |
The maximum length of the config table's value column in bytes. More... | |
#define | FTS_ILIST_MAX_SIZE (64 * 1024) |
Approx. More... | |
#define | FTS_OPTIMIZE_LIMIT_IN_SECS "optimize_checkpoint_limit" |
FTS config table name parameters. More... | |
#define | FTS_SYNCED_DOC_ID "synced_doc_id" |
The next doc id. More... | |
#define | FTS_LAST_OPTIMIZED_WORD "last_optimized_word" |
The last word that was OPTIMIZED. More... | |
#define | FTS_TOTAL_DELETED_COUNT "deleted_doc_count" |
Total number of documents that have been deleted. More... | |
#define | FTS_TOTAL_WORD_COUNT "total_word_count" |
Total number of words parsed from all documents. More... | |
#define | FTS_OPTIMIZE_START_TIME "optimize_start_time" |
Start of optimize of an FTS index. More... | |
#define | FTS_OPTIMIZE_END_TIME "optimize_end_time" |
End of optimize for an FTS index. More... | |
#define | FTS_STOPWORD_TABLE_NAME "stopword_table_name" |
User specified stopword table name. More... | |
#define | FTS_USE_STOPWORD "use_stopword" |
Whether to use (turn on/off) stopword. More... | |
#define | FTS_TABLE_STATE "table_state" |
State of the FTS system for this table. More... | |
#define | FTS_AUX_MIN_TABLE_ID_LENGTH 48 |
The minimum length of an FTS auxiliary table names's id component e.g., For an auxiliary table name. More... | |
#define | FTS_MAX_INT_LEN 32 |
Maximum length of an integer stored in the config table value column. More... | |
#define | FTS_FETCH_DOC_BY_ID_EQUAL 1 |
define for fts_doc_fetch_by_doc_id() "option" value, defines whether we want to get Doc whose ID is equal to or greater or smaller than supplied ID More... | |
#define | FTS_FETCH_DOC_BY_ID_LARGE 2 |
Typedefs | |
typedef enum fts_table_state_enum | fts_table_state_t |
Enumerations | |
enum | fts_table_state_enum { FTS_TABLE_STATE_RUNNING = 0 , FTS_TABLE_STATE_OPTIMIZING , FTS_TABLE_STATE_DELETED } |
Functions | |
que_t * | fts_parse_sql (fts_table_t *fts_table, pars_info_t *info, const char *sql) |
Parse an SQL string. More... | |
dberr_t | fts_eval_sql (trx_t *trx, que_t *graph) |
Evaluate a parsed SQL statement. More... | |
void | fts_get_table_name (const fts_table_t *fts_table, char *table_name) |
Construct the name of an ancillary FTS table for the given table. More... | |
void | fts_get_table_name_5_7 (const fts_table_t *fts_table, char *table_name) |
Construct the name of an ancillary FTS table for the given table in 5.7 compatible format. More... | |
const char * | fts_get_select_columns_str (dict_index_t *index, pars_info_t *info, mem_heap_t *heap) |
Construct the column specification part of the SQL string for selecting the indexed FTS columns for the given table. More... | |
dberr_t | fts_doc_fetch_by_doc_id (fts_get_doc_t *get_doc, doc_id_t doc_id, dict_index_t *index_to_use, ulint option, fts_sql_callback callback, void *arg) |
Fetch document (= a single row's indexed text) with the given document id. More... | |
bool | fts_query_expansion_fetch_doc (void *row, void *user_arg) |
Callback function for fetch that stores the text of an FTS document, converting each column to UTF-16. More... | |
dberr_t | fts_write_node (trx_t *trx, que_t **graph, fts_table_t *fts_table, fts_string_t *word, fts_node_t *node) |
in: node columns More... | |
bool | fts_check_token (const fts_string_t *token, const ib_rbt_t *stopwords, bool is_ngram, const CHARSET_INFO *cs) |
Check fts token. More... | |
void | fts_doc_init (fts_doc_t *doc) |
Initialize a document. More... | |
int | fts_bsearch (fts_update_t *array, int lower, int upper, doc_id_t doc_id) |
Do a binary search for a doc id in the array. More... | |
void | fts_doc_free (fts_doc_t *doc) |
Free document. More... | |
void | fts_word_free (fts_word_t *word) |
Free fts_optimizer_word_t instanace. More... | |
dberr_t | fts_index_fetch_nodes (trx_t *trx, que_t **graph, fts_table_t *fts_table, const fts_string_t *word, fts_fetch_t *fetch) |
Read the rows from the FTS inde. More... | |
static int | fts_trx_table_cmp (const void *v1, const void *v2) |
Compare two fts_trx_table_t instances, we actually compare the table id's here. More... | |
static int | fts_trx_table_id_cmp (const void *p1, const void *p2) |
Compare a table id with a trx_table_t table id. More... | |
dberr_t | fts_sql_commit (trx_t *trx) |
Commit a transaction. More... | |
dberr_t | fts_sql_rollback (trx_t *trx) |
Rollback a transaction. More... | |
dberr_t | fts_config_get_value (trx_t *trx, fts_table_t *fts_table, const char *name, fts_string_t *value) |
Get value from config table. More... | |
dberr_t | fts_config_get_index_value (trx_t *trx, dict_index_t *index, const char *param, fts_string_t *value) |
Get value specific to an FTS index from the config table. More... | |
dberr_t | fts_config_set_value (trx_t *trx, fts_table_t *fts_table, const char *name, const fts_string_t *value) |
Set the value in the config table for name. More... | |
dberr_t | fts_config_set_ulint (trx_t *trx, fts_table_t *fts_table, const char *name, ulint int_value) |
Set an ulint value in the config table. More... | |
dberr_t | fts_config_set_index_value (trx_t *trx, dict_index_t *index, const char *param, fts_string_t *value) |
Set the value specific to an FTS index in the config table. More... | |
dberr_t | fts_config_get_ulint (trx_t *trx, fts_table_t *fts_table, const char *name, ulint *int_value) |
Get an ulint value from the config table. More... | |
const ib_vector_t * | fts_cache_find_word (const fts_index_cache_t *index_cache, const fts_string_t *text) |
Search cache for word. More... | |
void | fts_cache_append_deleted_doc_ids (const fts_cache_t *cache, ib_vector_t *vector) |
Append deleted doc ids to vector and sort the vector. More... | |
bool | fts_wait_for_background_thread_to_start (dict_table_t *table, std::chrono::microseconds max_wait) |
Wait for the background thread to start. More... | |
fts_index_cache_t * | fts_find_index_cache (const fts_cache_t *cache, const dict_index_t *index) |
Search the index specific cache for a particular FTS index. More... | |
static int | fts_write_object_id (ib_id_t id, char *str) |
Write the table id to the given buffer (including final NUL). More... | |
static bool | fts_read_object_id (ib_id_t *id, const char *str) |
Read the table id from the string generated by fts_write_object_id(). More... | |
int | fts_get_table_id (const fts_table_t *fts_table, char *table_id) |
Get the table id. More... | |
void | fts_optimize_add_table (dict_table_t *table) |
Add the table to add to the OPTIMIZER's list. More... | |
char * | fts_get_table_name_prefix (const fts_table_t *fts_table) |
Construct the prefix name of an FTS table. More... | |
void | fts_cache_node_add_positions (fts_cache_t *cache, fts_node_t *node, doc_id_t doc_id, ib_vector_t *positions) |
Add node positions. More... | |
char * | fts_config_create_index_param_name (const char *param, const dict_index_t *index) |
Create the config table name for retrieving index specific value. More... | |
Variables | |
constexpr std::chrono::milliseconds | FTS_MAX_BACKGROUND_THREAD_WAIT {10} |
The default time to wait for the background thread. More... | |
Full text search internal header file.
Created 2011/09/02 Sunny Bains
#define FTS_AUX_MIN_TABLE_ID_LENGTH 48 |
The minimum length of an FTS auxiliary table names's id component e.g., For an auxiliary table name.
"FTS_@<TABLE_ID@>_SUFFIX"
This constant is for the minimum length required to store the <TABLE_ID> component.
#define FTS_BACKGROUND_THREAD_WAIT_COUNT 1000 |
Maximum number of iterations to wait before we complain.
#define FTS_FETCH_DOC_BY_ID_EQUAL 1 |
define for fts_doc_fetch_by_doc_id() "option" value, defines whether we want to get Doc whose ID is equal to or greater or smaller than supplied ID
#define FTS_FETCH_DOC_BY_ID_LARGE 2 |
#define FTS_ILIST_MAX_SIZE (64 * 1024) |
Approx.
upper limit of ilist length in bytes.
#define FTS_LAST_OPTIMIZED_WORD "last_optimized_word" |
The last word that was OPTIMIZED.
#define FTS_MAX_CONFIG_NAME_LEN 64 |
The maximum length of the config table's value column in bytes.
#define FTS_MAX_CONFIG_VALUE_LEN 1024 |
The maximum length of the config table's value column in bytes.
#define FTS_MAX_INT_LEN 32 |
Maximum length of an integer stored in the config table value column.
#define FTS_OPTIMIZE_END_TIME "optimize_end_time" |
End of optimize for an FTS index.
#define FTS_OPTIMIZE_LIMIT_IN_SECS "optimize_checkpoint_limit" |
FTS config table name parameters.
The number of seconds after which an OPTIMIZE run will stop
#define FTS_OPTIMIZE_START_TIME "optimize_start_time" |
Start of optimize of an FTS index.
#define FTS_STOPWORD_TABLE_NAME "stopword_table_name" |
User specified stopword table name.
#define FTS_SYNCED_DOC_ID "synced_doc_id" |
The next doc id.
#define FTS_TABLE_STATE "table_state" |
State of the FTS system for this table.
It can be one of RUNNING, OPTIMIZING, DELETED.
#define FTS_TOTAL_DELETED_COUNT "deleted_doc_count" |
Total number of documents that have been deleted.
The next_doc_id minus this count gives us the total number of documents.
#define FTS_TOTAL_WORD_COUNT "total_word_count" |
Total number of words parsed from all documents.
#define FTS_USE_STOPWORD "use_stopword" |
Whether to use (turn on/off) stopword.
typedef enum fts_table_state_enum fts_table_state_t |
enum fts_table_state_enum |
int fts_bsearch | ( | fts_update_t * | array, |
int | lower, | ||
int | upper, | ||
doc_id_t | doc_id | ||
) |
Do a binary search for a doc id in the array.
array | in: array to sort |
lower | in: the array lower bound |
upper | in: the array upper bound |
doc_id | in: the doc id to search for |
void fts_cache_append_deleted_doc_ids | ( | const fts_cache_t * | cache, |
ib_vector_t * | vector | ||
) |
Append deleted doc ids to vector and sort the vector.
in: append to this vector
Append deleted doc ids to vector and sort the vector.
cache | in: cache to use |
vector | in: append to this vector |
const ib_vector_t * fts_cache_find_word | ( | const fts_index_cache_t * | index_cache, |
const fts_string_t * | text | ||
) |
Search cache for word.
index_cache | in: cache to search |
text | in: word to search for |
void fts_cache_node_add_positions | ( | fts_cache_t * | cache, |
fts_node_t * | node, | ||
doc_id_t | doc_id, | ||
ib_vector_t * | positions | ||
) |
Add node positions.
in: fts_token_t::positions
Add node positions.
cache | in: cache |
node | in: word node |
doc_id | in: doc id |
positions | in: fts_token_t::positions |
bool fts_check_token | ( | const fts_string_t * | token, |
const ib_rbt_t * | stopwords, | ||
bool | is_ngram, | ||
const CHARSET_INFO * | cs | ||
) |
Check fts token.
[in] | token | token string |
[in] | stopwords | stopwords rb tree |
[in] | is_ngram | is ngram parser |
[in] | cs | token charset |
true | if it is not stopword and length in range |
false | if it is stopword or length not in range |
char * fts_config_create_index_param_name | ( | const char * | param, |
const dict_index_t * | index | ||
) |
Create the config table name for retrieving index specific value.
param | in: base name of param |
index | in: index for config |
dberr_t fts_config_get_index_value | ( | trx_t * | trx, |
dict_index_t * | index, | ||
const char * | param, | ||
fts_string_t * | value | ||
) |
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.
The caller must ensure that enough space is allocated for value to hold the column contents.
trx | transaction |
index | in: index |
param | in: get config value for this parameter name |
value | out: value read from config table |
dberr_t fts_config_get_ulint | ( | trx_t * | trx, |
fts_table_t * | fts_table, | ||
const char * | name, | ||
ulint * | int_value | ||
) |
Get an ulint value from the config table.
trx | in: transaction |
fts_table | in: the indexed FTS table |
name | in: param name |
int_value | out: value |
dberr_t fts_config_get_value | ( | trx_t * | trx, |
fts_table_t * | fts_table, | ||
const char * | name, | ||
fts_string_t * | value | ||
) |
Get value from config table.
The caller must ensure that enough space is allocated for value to hold the column contents
Get value from config table.
The caller must ensure that enough space is allocated for value to hold the column contents.
trx | transaction |
fts_table | in: the indexed FTS table |
name | in: get config value for this parameter name |
value | out: value read from config table |
dberr_t fts_config_set_index_value | ( | trx_t * | trx, |
dict_index_t * | index, | ||
const char * | param, | ||
fts_string_t * | value | ||
) |
Set the value specific to an FTS index in the config table.
trx | transaction |
index | in: index |
param | in: get config value for this parameter name |
value | out: value read from config table |
dberr_t fts_config_set_ulint | ( | trx_t * | trx, |
fts_table_t * | fts_table, | ||
const char * | name, | ||
ulint | int_value | ||
) |
Set an ulint value in the config table.
trx | in: transaction |
fts_table | in: the indexed FTS table |
name | in: param name |
int_value | in: value |
dberr_t fts_config_set_value | ( | trx_t * | trx, |
fts_table_t * | fts_table, | ||
const char * | name, | ||
const fts_string_t * | value | ||
) |
Set the value in the config table for name.
trx | transaction |
fts_table | in: the indexed FTS table |
name | in: get config value for this parameter name |
value | in: value to update |
dberr_t fts_doc_fetch_by_doc_id | ( | fts_get_doc_t * | get_doc, |
doc_id_t | doc_id, | ||
dict_index_t * | index_to_use, | ||
ulint | option, | ||
fts_sql_callback | callback, | ||
void * | arg | ||
) |
Fetch document (= a single row's indexed text) with the given document id.
Fetch document (= a single row's indexed text) with the given document id.
get_doc | in: state |
doc_id | in: id of document to fetch |
index_to_use | in: caller supplied FTS index, or NULL |
option | in: search option, if it is greater than doc_id or equal |
callback | in: callback to read |
arg | in: callback arg |
void fts_doc_free | ( | fts_doc_t * | doc | ) |
Free document.
in: document
doc | in: document |
void fts_doc_init | ( | fts_doc_t * | doc | ) |
Initialize a document.
in: doc to initialize
doc | in: doc to initialize |
Evaluate a parsed SQL statement.
Evaluate a parsed SQL statement.
trx | in: transaction |
graph | in: Query graph to evaluate |
fts_index_cache_t * fts_find_index_cache | ( | const fts_cache_t * | cache, |
const dict_index_t * | index | ||
) |
Search the index specific cache for a particular FTS index.
cache | in: cache to search |
index | in: index to search for |
const char * fts_get_select_columns_str | ( | dict_index_t * | index, |
pars_info_t * | info, | ||
mem_heap_t * | heap | ||
) |
Construct the column specification part of the SQL string for selecting the indexed FTS columns for the given table.
Adds the necessary bound ids to the given 'info' and returns the SQL string. Examples:
One indexed column named "text":
"$sel0", info/ids: sel0 -> "text"
Two indexed columns named "subject" and "content":
"$sel0, $sel1", info/ids: sel0 -> "subject", sel1 -> "content",
Adds the necessary bound ids to the given 'info' and returns the SQL string. Examples:
One indexed column named "text":
"$sel0", info/ids: sel0 -> "text"
Two indexed columns named "subject" and "content":
"$sel0, $sel1", info/ids: sel0 -> "subject", sel1 -> "content",
index | in: index |
info | in/out: parser info |
heap | in: memory heap |
int fts_get_table_id | ( | const fts_table_t * | fts_table, |
char * | table_id | ||
) |
Get the table id.
fts_table | in: FTS Auxiliary table |
table_id | out: table id, must be at least FTS_AUX_MIN_TABLE_ID_LENGTH bytes long |
void fts_get_table_name | ( | const fts_table_t * | fts_table, |
char * | table_name | ||
) |
Construct the name of an ancillary FTS table for the given table.
Caller must allocate enough memory(usually size of MAX_FULL_NAME_LEN) for param 'table_name'. in/out: aux table name
Caller must allocate enough memory(usually size of MAX_FULL_NAME_LEN) for param 'table_name'.
fts_table | in: Auxiliary table type |
table_name | in/out: aux table name |
void fts_get_table_name_5_7 | ( | const fts_table_t * | fts_table, |
char * | table_name | ||
) |
Construct the name of an ancillary FTS table for the given table in 5.7 compatible format.
Caller must allocate enough memory(usually size of MAX_FULL_NAME_LEN) for param 'table_name'
[in] | fts_table | Auxiliary table object |
[in,out] | table_name | aux table name |
char * fts_get_table_name_prefix | ( | const fts_table_t * | fts_table | ) |
Construct the prefix name of an FTS table.
fts_table | in: Auxiliary table type |
dberr_t fts_index_fetch_nodes | ( | trx_t * | trx, |
que_t ** | graph, | ||
fts_table_t * | fts_table, | ||
const fts_string_t * | word, | ||
fts_fetch_t * | fetch | ||
) |
Read the rows from the FTS inde.
trx | in: transaction |
graph | in: prepared statement |
fts_table | in: table of the FTS INDEX |
word | in: the word to fetch |
fetch | in: fetch callback. |
void fts_optimize_add_table | ( | dict_table_t * | table | ) |
Add the table to add to the OPTIMIZER's list.
in: table to add
table | in: table to add |
que_t * fts_parse_sql | ( | fts_table_t * | fts_table, |
pars_info_t * | info, | ||
const char * | sql | ||
) |
Parse an SQL string.
s is replaced with the table's id.
fts_table | in: FTS auxiliarry table info |
info | in: info struct, or NULL |
sql | in: SQL string to evaluate |
bool fts_query_expansion_fetch_doc | ( | void * | row, |
void * | user_arg | ||
) |
Callback function for fetch that stores the text of an FTS document, converting each column to UTF-16.
row | in: sel_node_t* |
user_arg | in: fts_doc_t* |
|
inlinestatic |
Read the table id from the string generated by fts_write_object_id().
[out] | id | Table ID. |
[in] | str | Buffer to read from. |
Commit a transaction.
trx | in: transaction |
Rollback a transaction.
trx | in: transaction |
|
inlinestatic |
Compare two fts_trx_table_t instances, we actually compare the table id's here.
[in] | v1 | id1 |
[in] | v2 | id2 |
|
inlinestatic |
Compare a table id with a trx_table_t table id.
[in] | p1 | id1 |
[in] | p2 | id2 |
bool fts_wait_for_background_thread_to_start | ( | dict_table_t * | table, |
std::chrono::microseconds | max_wait | ||
) |
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.
[in] | table | table to which the thread is attached |
[in] | max_wait | Time to wait. If set to 0 then it disables timeout checking |
void fts_word_free | ( | fts_word_t * | word | ) |
Free fts_optimizer_word_t instanace.
in: instance to free.
word | in: instance to free. |
dberr_t fts_write_node | ( | trx_t * | trx, |
que_t ** | graph, | ||
fts_table_t * | fts_table, | ||
fts_string_t * | word, | ||
fts_node_t * | node | ||
) |
in: node columns
in: node columns
trx | in: transaction |
graph | in: query graph |
fts_table | in: aux table |
word | in: word in UTF-8 |
node | in: node columns |
|
inlinestatic |
Write the table id to the given buffer (including final NUL).
Buffer must be at least FTS_AUX_MIN_TABLE_ID_LENGTH bytes long.
[in] | id | a table/index id |
[in] | str | buffer to write the id to |
|
constexpr |
The default time to wait for the background thread.