MySQL 8.0.40
Source Code Documentation
|
Full Text Search interface. More...
#include <current_thd.h>
#include <sys/types.h>
#include <new>
#include "btr0pcur.h"
#include "dict0priv.h"
#include "dict0stats.h"
#include "dict0types.h"
#include "fts0fts.h"
#include "fts0plugin.h"
#include "fts0priv.h"
#include "fts0types.h"
#include "fts0types.ic"
#include "fts0vlc.ic"
#include "ha_prototypes.h"
#include "lob0lob.h"
#include "my_dbug.h"
#include "dict0dd.h"
#include "row0mysql.h"
#include "row0sel.h"
#include "row0upd.h"
#include "sync0sync.h"
#include "trx0roll.h"
#include "ut0new.h"
Classes | |
struct | fts_tokenize_param_t |
FTS tokenize parameter for plugin parser. More... | |
Macros | |
#define | FTS_MAX_CACHE_SIZE_IN_MB "cache_size_in_mb" |
Column name from the FTS config table. More... | |
#define | FTS_IS_OBSOLETE_AUX_TABLE(table_name) |
Verify if a aux table name is a obsolete table by looking up the key word in the obsolete table names. More... | |
Functions | |
static dberr_t | fts_sync (fts_sync_t *sync, bool unlock_cache, bool wait, bool has_dict) |
Run SYNC on the table, i.e., write out data from the cache to the FTS auxiliary INDEX table and clear the cache at the end. More... | |
static void | fts_words_free (ib_rbt_t *words) |
Release all resources help by the words rb tree e.g., the node ilist. More... | |
static ulint | fts_add_doc_by_id (fts_trx_table_t *ftt, doc_id_t doc_id, ib_vector_t *fts_indexes) |
This function fetches the document just inserted right before we commit the transaction, and tokenize the inserted text data and insert into FTS auxiliary table and its cache. More... | |
static dberr_t | fts_update_sync_doc_id (const dict_table_t *table, const char *table_name, doc_id_t doc_id, trx_t *trx) |
Update the last document id. More... | |
static void | fts_tokenize_document (fts_doc_t *doc, fts_doc_t *result, st_mysql_ftparser *parser) |
Tokenize a document. More... | |
static void | fts_tokenize_document_next (fts_doc_t *doc, ulint add_pos, fts_doc_t *result, st_mysql_ftparser *parser) |
Continue to tokenize a document. More... | |
static ib_vector_t * | fts_get_docs_create (fts_cache_t *cache) |
Create the vector of fts_get_doc_t instances. More... | |
static void | fts_cache_destroy (fts_cache_t *cache) |
Free the FTS cache. More... | |
static CHARSET_INFO * | fts_get_charset (ulint prtype) |
Get a character set based on precise type. More... | |
static void | fts_load_default_stopword (fts_stopword_t *stopword_info) |
This function loads the default InnoDB stopword list. More... | |
static bool | fts_read_stopword (void *row, void *user_arg) |
Callback function to read a single stopword value. More... | |
static bool | fts_load_user_stopword (const char *stopword_table_name, fts_stopword_t *stopword_info) |
Load user defined stopword from designated user table. More... | |
static void | fts_index_cache_init (ib_alloc_t *allocator, fts_index_cache_t *index_cache) |
Initialize the index cache. More... | |
void | fts_cache_init (fts_cache_t *cache) |
Initialize FTS cache. More... | |
fts_cache_t * | fts_cache_create (dict_table_t *table) |
Create a FTS cache. More... | |
void | fts_add_index (dict_index_t *index, dict_table_t *table) |
Add a newly create index into FTS cache. More... | |
static void | fts_reset_get_doc (fts_cache_t *cache) |
recalibrate get_doc structure after index_cache in cache->indexes changed More... | |
static bool | fts_in_dict_index (dict_table_t *table, dict_index_t *index_check) |
Check an index is in the table->indexes list. More... | |
static bool | fts_in_index_cache (dict_table_t *table, dict_index_t *index) |
Check an index is in the fts->cache->indexes list. More... | |
bool | fts_check_cached_index (dict_table_t *table) |
Check indexes in the fts->indexes is also present in index cache and table->indexes list. More... | |
dberr_t | fts_drop_index (dict_table_t *table, dict_index_t *index, trx_t *trx, aux_name_vec_t *aux_vec, bool adding_another) |
Drop auxiliary tables related to an FTS index. More... | |
CHARSET_INFO * | fts_index_get_charset (dict_index_t *index) |
Create an FTS index cache. More... | |
fts_index_cache_t * | fts_cache_index_cache_create (dict_table_t *table, dict_index_t *index) |
Create an FTS index cache. More... | |
void | fts_cache_index_cache_remove (dict_table_t *table, dict_index_t *index) |
Remove a FTS index cache. More... | |
void | fts_cache_clear (fts_cache_t *cache) |
Clear cache. More... | |
static fts_index_cache_t * | fts_get_index_cache (fts_cache_t *cache, const dict_index_t *index) |
Search the index specific cache for a particular FTS index. More... | |
static fts_tokenizer_word_t * | fts_tokenizer_word_get (fts_cache_t *cache, fts_index_cache_t *index_cache, fts_string_t *text) |
Find an existing word, or if not found, create one and return it. 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 the given doc_id/word positions to the given node's ilist. More... | |
static void | fts_cache_add_doc (fts_cache_t *cache, fts_index_cache_t *index_cache, doc_id_t doc_id, ib_rbt_t *tokens) |
Add document to the cache. More... | |
bool | fts_drop_dd_tables (const aux_name_vec_t *aux_vec, bool file_per_table) |
Drop FTS AUX table DD table objects in vector. More... | |
void | fts_free_aux_names (aux_name_vec_t *aux_vec) |
Free FTS AUX table names in vector. More... | |
static dberr_t | fts_drop_table (trx_t *trx, const char *table_name, aux_name_vec_t *aux_vec) |
Drops a table. More... | |
static dberr_t | fts_rename_one_aux_table (const char *new_name, const char *fts_table_old_name, trx_t *trx, bool replay) |
Rename a single auxiliary table due to database name change. More... | |
dberr_t | fts_rename_aux_tables (dict_table_t *table, const char *new_name, trx_t *trx, bool replay) |
Rename auxiliary tables for all fts index for a table. More... | |
static dberr_t | fts_drop_common_tables (trx_t *trx, fts_table_t *fts_table, aux_name_vec_t *aux_vec) |
Drops the common ancillary tables needed for supporting an FTS index on the given table. More... | |
dberr_t | fts_drop_index_tables (trx_t *trx, dict_index_t *index, aux_name_vec_t *aux_vec) |
Since we do a horizontal split on the index table, we need to drop all the split tables. More... | |
static dberr_t | fts_init_config_table (fts_table_t *fts_table) |
Write the default settings to the config table. More... | |
static dberr_t | fts_empty_table (trx_t *trx, fts_table_t *fts_table) |
Empty a common talbes. More... | |
dberr_t | fts_empty_common_tables (trx_t *trx, dict_table_t *table) |
Empty all common talbes. More... | |
static dberr_t | fts_drop_all_index_tables (trx_t *trx, fts_t *fts, aux_name_vec_t *aux_vec) |
Drops FTS ancillary tables needed for supporting an FTS index on the given table. More... | |
dberr_t | fts_drop_tables (trx_t *trx, dict_table_t *table, aux_name_vec_t *aux_vec) |
Drops the ancillary tables needed for supporting an FTS index on a given table. More... | |
static dberr_t | fts_lock_common_tables (THD *thd, fts_table_t *fts_table) |
Lock all FTS AUX COMMON tables (for dropping table) More... | |
dberr_t | fts_lock_index_tables (THD *thd, dict_index_t *index) |
Lock all FTS INDEX AUX tables (for dropping table) More... | |
static dberr_t | fts_lock_all_index_tables (THD *thd, fts_t *fts) |
Lock all FTS index AUX tables (for dropping table) More... | |
dberr_t | fts_lock_all_aux_tables (THD *thd, dict_table_t *table) |
Lock all FTS AUX tables (for dropping table) More... | |
static uint32_t | fts_get_table_flags2_for_aux_tables (uint32_t flags2) |
Extract only the required flags from table->flags2 for FTS Aux tables. More... | |
static dict_table_t * | fts_create_in_mem_aux_table (const char *aux_table_name, const dict_table_t *table, ulint n_cols) |
Create dict_table_t object for FTS Aux tables. More... | |
static dict_table_t * | fts_create_one_common_table (trx_t *trx, const dict_table_t *table, const char *fts_table_name, const char *fts_suffix, mem_heap_t *heap) |
Function to create on FTS common table. More... | |
bool | fts_check_common_tables_exist (const dict_table_t *table) |
Check if common tables already exist. More... | |
dberr_t | fts_create_common_tables (trx_t *trx, const dict_table_t *table, const char *name, bool skip_doc_id_index) |
Creates the common auxiliary tables needed for supporting an FTS index on the given table. More... | |
static dict_table_t * | fts_create_one_index_table (trx_t *trx, const dict_index_t *index, fts_table_t *fts_table, mem_heap_t *heap) |
Creates one FTS auxiliary index table for an FTS index. More... | |
void | fts_freeze_aux_tables (const dict_table_t *table) |
Freeze all auiliary tables to be not evictable if exist, with dict_mutex held. More... | |
void | fts_detach_aux_tables (const dict_table_t *table, bool dict_locked) |
Allow all the auxiliary tables of specified base table to be evictable if they exist, if not exist just ignore. More... | |
bool | fts_create_common_dd_tables (const dict_table_t *table) |
Update DD system table for auxiliary common tables for an FTS index. More... | |
static dberr_t | fts_create_one_index_dd_tables (const dict_index_t *index) |
Update DD system table for auxiliary index tables for an FTS index. More... | |
dberr_t | fts_create_index_dd_tables (dict_table_t *table) |
Check if a table has FTS index needs to have its auxiliary index tables' metadata updated in DD. More... | |
dberr_t | fts_create_index_tables_low (trx_t *trx, dict_index_t *index, const char *table_name, table_id_t table_id) |
Create auxiliary index tables for an FTS index. More... | |
dberr_t | fts_create_index_tables (trx_t *trx, dict_index_t *index) |
Creates the column specific ancillary tables needed for supporting an FTS index on the given table. More... | |
static fts_row_state | fts_trx_row_get_new_state (fts_row_state old_state, fts_row_state event) |
Calculate the new state of a row given the existing state and a new event. More... | |
static fts_savepoint_t * | fts_savepoint_create (ib_vector_t *savepoints, const char *name, mem_heap_t *heap) |
Create a savepoint instance. More... | |
fts_trx_t * | fts_trx_create (trx_t *trx) |
Create an FTS trx. More... | |
static fts_trx_table_t * | fts_trx_table_create (fts_trx_t *fts_trx, dict_table_t *table) |
Create an FTS trx table. More... | |
static fts_trx_table_t * | fts_trx_table_clone (const fts_trx_table_t *ftt_src) |
Clone an FTS trx table. More... | |
static fts_trx_table_t * | fts_trx_init (trx_t *trx, dict_table_t *table, ib_vector_t *savepoints) |
Initialize the FTS trx instance. More... | |
static void | fts_trx_table_add_op (fts_trx_table_t *ftt, doc_id_t doc_id, fts_row_state state, ib_vector_t *fts_indexes) |
Notify the FTS system about an operation on an FTS-indexed table. More... | |
void | fts_trx_add_op (trx_t *trx, dict_table_t *table, doc_id_t doc_id, fts_row_state state, ib_vector_t *fts_indexes) |
Notify the FTS system about an operation on an FTS-indexed table. More... | |
static bool | fts_fetch_store_doc_id (void *row, void *user_arg) |
Fetch callback that converts a textual document id to a binary value and stores it in the given place. More... | |
void | fts_update_next_doc_id (trx_t *trx, const dict_table_t *table, const char *table_name, doc_id_t doc_id) |
Update the next and last Doc ID in the CONFIG table to be the input "doc_id" value (+ 1). More... | |
dberr_t | fts_get_next_doc_id (const dict_table_t *table, doc_id_t *doc_id) |
Get the next available document id. More... | |
static dberr_t | fts_cmp_set_sync_doc_id (const dict_table_t *table, doc_id_t doc_id_cmp, bool read_only, doc_id_t *doc_id, trx_t *trx=nullptr) |
This function fetch the Doc ID from CONFIG table, and compare with the Doc ID supplied. More... | |
fts_doc_ids_t * | fts_doc_ids_create (void) |
Create a new fts_doc_ids_t. More... | |
void | fts_doc_ids_free (fts_doc_ids_t *fts_doc_ids) |
Free a fts_doc_ids_t. More... | |
static void | fts_add (fts_trx_table_t *ftt, fts_trx_row_t *row) |
Do commit-phase steps necessary for the insertion of a new row. More... | |
static dberr_t | fts_delete (fts_trx_table_t *ftt, fts_trx_row_t *row) |
Do commit-phase steps necessary for the deletion of a row. More... | |
static dberr_t | fts_modify (fts_trx_table_t *ftt, fts_trx_row_t *row) |
Do commit-phase steps necessary for the modification of a row. More... | |
dberr_t | fts_create_doc_id (dict_table_t *table, dtuple_t *row, mem_heap_t *heap) |
Create a new document id. More... | |
static dberr_t | fts_commit_table (fts_trx_table_t *ftt) |
The given transaction is about to be committed; do whatever is necessary from the FTS system's POV. More... | |
dberr_t | fts_commit (trx_t *trx) |
The given transaction is about to be committed; do whatever is necessary from the FTS system's POV. More... | |
void | fts_doc_init (fts_doc_t *doc) |
Initialize a document. More... | |
void | fts_doc_free (fts_doc_t *doc) |
Free document. 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... | |
static void | fts_fetch_doc_from_rec (fts_get_doc_t *get_doc, dict_index_t *clust_index, btr_pcur_t *pcur, ulint *offsets, fts_doc_t *doc) |
fetch and tokenize the document. More... | |
static void | fts_fetch_doc_from_tuple (fts_get_doc_t *get_doc, const dtuple_t *tuple, fts_doc_t *doc) |
Fetch the data from tuple and tokenize the document. More... | |
void | fts_add_doc_from_tuple (fts_trx_table_t *ftt, doc_id_t doc_id, const dtuple_t *tuple) |
Fetch the document from tuple, tokenize the text data and insert the text data into fts auxiliary table and its cache. More... | |
static bool | fts_read_ulint (void *row, void *user_arg) |
Callback function to read a single ulint column. More... | |
doc_id_t | fts_get_max_doc_id (dict_table_t *table) |
Get maximum Doc ID in a table if index "FTS_DOC_ID_INDEX" exists. 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 with the given document id. 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) |
Write out a single word's data as new entry/entries in the INDEX table. More... | |
static dberr_t | fts_sync_add_deleted_cache (fts_sync_t *sync, ib_vector_t *doc_ids) |
Add rows to the DELETED_CACHE table. More... | |
static dberr_t | fts_sync_write_words (trx_t *trx, fts_index_cache_t *index_cache, bool unlock_cache, std::chrono::steady_clock::time_point sync_start_time) |
Write the words and ilist to disk. More... | |
static void | fts_sync_begin (fts_sync_t *sync) |
Begin Sync, create transaction, acquire locks, etc. More... | |
static dberr_t | fts_sync_index (fts_sync_t *sync, fts_index_cache_t *index_cache) |
Run SYNC on the table, i.e., write out data from the index specific cache to the FTS aux INDEX table and FTS aux doc id stats table. More... | |
static bool | fts_sync_index_check (fts_index_cache_t *index_cache) |
Check if index cache has been synced completely. More... | |
static void | fts_sync_index_reset (fts_index_cache_t *index_cache) |
Reset synced flag in index cache when rollback. More... | |
static dberr_t | fts_sync_commit (fts_sync_t *sync) |
Commit the SYNC, change state of processed doc ids etc. More... | |
static void | fts_sync_rollback (fts_sync_t *sync) |
Rollback a sync operation. More... | |
dberr_t | fts_sync_table (dict_table_t *table, bool unlock_cache, bool wait, bool has_dict) |
Run SYNC on the table, i.e., write out data from the cache to the FTS auxiliary INDEX table and clear the cache at the end. 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... | |
static void | fts_add_token (fts_doc_t *result_doc, fts_string_t str, ulint position) |
Add the token and its start position to the token's list of positions. More... | |
static ulint | fts_process_token (fts_doc_t *doc, fts_doc_t *result, ulint start_pos, ulint add_pos) |
Process next token from document starting at the given position, i.e., add the token's start position to the token's list of positions. More... | |
ulint | fts_get_token_size (const CHARSET_INFO *cs, const char *token, ulint len) |
Get token char size by charset. More... | |
int | fts_tokenize_document_internal (MYSQL_FTPARSER_PARAM *param, char *doc, int len) |
FTS plugin parser 'myql_parser' callback function for document tokenize. More... | |
static int | fts_tokenize_add_word_for_parser (MYSQL_FTPARSER_PARAM *param, char *word, int word_len, MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info) |
FTS plugin parser 'myql_add_word' callback function for document tokenize. More... | |
static void | fts_tokenize_by_parser (fts_doc_t *doc, st_mysql_ftparser *parser, fts_tokenize_param_t *fts_param) |
Parse a document using an external / user supplied parser. More... | |
static void | fts_get_docs_clear (ib_vector_t *get_docs) |
doc_id_t | fts_init_doc_id (const dict_table_t *table) |
Get the initial Doc ID by consulting the CONFIG table. More... | |
ulint | fts_get_rows_count (fts_table_t *fts_table) |
Fetch COUNT(*) from specified table. More... | |
static void | fts_trx_table_rows_free (ib_rbt_t *rows) |
Free the modified rows of a table. More... | |
static void | fts_savepoint_free (fts_savepoint_t *savepoint) |
Free an FTS savepoint instance. More... | |
void | fts_trx_free (fts_trx_t *fts_trx) |
Free an FTS trx. More... | |
doc_id_t | fts_get_doc_id_from_row (dict_table_t *table, dtuple_t *row) |
Extract the doc id from the FTS hidden column. More... | |
doc_id_t | fts_get_doc_id_from_rec (dict_table_t *table, const rec_t *rec, const dict_index_t *index, mem_heap_t *heap) |
Extract the doc id from the record that belongs to index. 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... | |
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. 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... | |
void | fts_add_doc_id_column (dict_table_t *table, mem_heap_t *heap) |
Add the FTS document id hidden column. More... | |
doc_id_t | fts_update_doc_id (dict_table_t *table, upd_field_t *ufield, doc_id_t *next_doc_id) |
Add new fts doc id to the update vector. More... | |
fts_t * | fts_create (dict_table_t *table) |
Create an instance of fts_t. More... | |
void | fts_free (dict_table_t *table) |
Free the FTS resources. More... | |
static void | fts_savepoint_copy (const fts_savepoint_t *src, fts_savepoint_t *dst) |
Take a FTS savepoint. More... | |
void | fts_savepoint_take (fts_trx_t *fts_trx, const char *name) |
Take a FTS savepoint. More... | |
static ulint | fts_savepoint_lookup (ib_vector_t *savepoints, const char *name) |
Lookup a savepoint instance by name. More... | |
void | fts_savepoint_release (trx_t *trx, const char *name) |
Release the savepoint data identified by name. More... | |
void | fts_savepoint_laststmt_refresh (trx_t *trx) |
Refresh last statement savepoint. More... | |
static void | fts_undo_last_stmt (fts_trx_table_t *s_ftt, fts_trx_table_t *l_ftt) |
void | fts_savepoint_rollback_last_stmt (trx_t *trx) |
Rollback to savepoint identified by name. More... | |
void | fts_savepoint_rollback (trx_t *trx, const char *name) |
Rollback to savepoint identified by name. More... | |
bool | fts_is_aux_table_name (fts_aux_table_t *table, const char *name, ulint len) |
Check if a table is an FTS auxiliary table name. More... | |
CHARSET_INFO * | fts_valid_stopword_table (const char *stopword_table_name) |
Check whether user supplied stopword table is of the right format. More... | |
bool | fts_load_stopword (const dict_table_t *table, trx_t *trx, const char *global_stopword_table, const char *session_stopword_table, bool stopword_is_on, bool reload) |
This function loads the stopword into the FTS cache. More... | |
static bool | fts_init_get_doc_id (void *row, void *user_arg) |
Callback function when we initialize the FTS at the start up time. More... | |
static bool | fts_init_recover_doc (void *row, void *user_arg) |
Callback function when we initialize the FTS at the start up time. More... | |
bool | fts_init_index (dict_table_t *table, bool has_cache_lock) |
This function brings FTS index in sync when FTS index is first used. More... | |
static dict_table_t * | fts_upgrade_rename_aux_table_low (const char *old_name, const char *new_name) |
Rename old FTS common and aux tables with the new table_id. More... | |
static void | fts_upgrade_rename_aux_table (const char *old_name, const char *new_name, bool rollback) |
Rename old FTS common and aux tables with the new table_id. More... | |
table_id_t | fts_upgrade_get_5_7_table_id (table_id_t table_id) |
During upgrade, tables are moved by DICT_MAX_DD_TABLES offset, remove this offset to get 5.7 fts aux table names. More... | |
dberr_t | fts_upgrade_aux_tables (dict_table_t *table) |
Upgrade FTS AUX Tables. More... | |
dberr_t | fts_upgrade_rename (const dict_table_t *table, bool rollback) |
Rename FTS AUX tablespace name from 8.0 format to 5.7 format. More... | |
Variables | |
static const ulint | FTS_MAX_ID_LEN = 32 |
ulong | fts_max_cache_size |
This is maximum FTS cache for each table and would be a configurable variable. More... | |
bool | fts_need_sync = false |
Whether the total memory used for FTS cache is exhausted, and we will need a sync to free some memory. More... | |
ulong | fts_max_total_cache_size |
Variable specifying the total memory allocated for FTS cache. More... | |
ulong | fts_result_cache_limit |
This is FTS result cache limit for each query and would be a configurable variable. More... | |
ulong | fts_max_token_size |
Variable specifying the maximum FTS max token size. More... | |
ulong | fts_min_token_size |
Variable specifying the minimum FTS max token size. More... | |
static std::chrono::steady_clock::duration | elapsed_time |
static ulint | n_nodes = 0 |
static constexpr uint32_t | FTS_DEADLOCK_RETRY_WAIT_MS = 100 |
Time to sleep after DEADLOCK error before retrying operation in milliseconds. More... | |
char * | fts_internal_tbl_name = nullptr |
variable to record innodb_fts_internal_tbl_name for information schema table INNODB_FTS_INSERTED etc. More... | |
const char * | fts_default_stopword [] |
InnoDB default stopword list: There are different versions of stopwords, the stop words listed below comes from "Google Stopword" list. More... | |
const char * | FTS_PREFIX = "fts_" |
FTS auxiliary table prefix that are common to all FT indexes. More... | |
const char * | FTS_PREFIX_5_7 = "FTS_" |
FTS auxiliary table prefix that are common to all FT indexes. More... | |
const char * | fts_common_tables [] |
FTS auxiliary table suffixes that are common to all FT indexes. More... | |
const char * | FTS_SUFFIX_BEING_DELETED = fts_common_tables[0] |
const char * | FTS_SUFFIX_BEING_DELETED_CACHE = fts_common_tables[1] |
const char * | FTS_SUFFIX_CONFIG = fts_common_tables[2] |
const char * | FTS_SUFFIX_DELETED = fts_common_tables[3] |
const char * | FTS_SUFFIX_DELETED_CACHE = fts_common_tables[4] |
const char * | fts_common_tables_5_7 [] |
FTS auxiliary table suffixes that are common to all FT indexes. More... | |
const char * | FTS_SUFFIX_CONFIG_5_7 = fts_common_tables_5_7[2] |
const fts_index_selector_t | fts_index_selector [] |
FTS auxiliary INDEX split intervals. More... | |
const fts_index_selector_t | fts_index_selector_5_7 [] |
FTS auxiliary INDEX split intervals. More... | |
static const char * | fts_config_table_insert_values_sql |
Default config values for FTS indexes on a table. More... | |
Full Text Search interface.
#define FTS_IS_OBSOLETE_AUX_TABLE | ( | table_name | ) |
Verify if a aux table name is a obsolete table by looking up the key word in the obsolete table names.
#define FTS_MAX_CACHE_SIZE_IN_MB "cache_size_in_mb" |
Column name from the FTS config table.
|
static |
Do commit-phase steps necessary for the insertion of a new row.
[in] | ftt | FTS transaction table |
[in] | row | row to be inserted in index |
|
static |
This function fetches the document just inserted right before we commit the transaction, and tokenize the inserted text data and insert into FTS auxiliary table and its cache.
[in] | ftt | FTS transaction table |
[in] | doc_id | doc id |
[in] | fts_indexes | affected FTS indexes |
void fts_add_doc_from_tuple | ( | fts_trx_table_t * | ftt, |
doc_id_t | doc_id, | ||
const dtuple_t * | tuple | ||
) |
Fetch the document from tuple, tokenize the text data and insert the text data into fts auxiliary table and its cache.
Moreover this tuple fields doesn't contain any information about externally stored field. This tuple contains data directly converted from mysql.
[in] | ftt | FTS transaction table |
[in] | doc_id | doc id |
[in] | tuple | tuple from where data can be retrieved and tuple should be arranged in table schema order. |
void fts_add_doc_id_column | ( | dict_table_t * | table, |
mem_heap_t * | heap | ||
) |
Add the FTS document id hidden column.
[in,out] | table | Table with FTS index |
[in] | heap | Temporary memory heap, or NULL |
void fts_add_index | ( | dict_index_t * | index, |
dict_table_t * | table | ||
) |
Add a newly create index into FTS cache.
Add a newly create index in FTS cache.
index | FTS index to be added |
table | table |
|
static |
Add the token and its start position to the token's list of positions.
[in,out] | result_doc | result doc rb tree |
[in] | str | token string |
[in] | position | token position |
|
static |
Add document to the cache.
cache | in: cache |
index_cache | in: index cache |
doc_id | in: doc id to add |
tokens | in: document tokens |
void fts_cache_append_deleted_doc_ids | ( | const fts_cache_t * | cache, |
ib_vector_t * | vector | ||
) |
Append deleted doc ids to vector.
Append deleted doc ids to vector and sort the vector.
cache | in: cache to use |
vector | in: append to this vector |
void fts_cache_clear | ( | fts_cache_t * | cache | ) |
Clear cache.
[in,out] | cache | fts cache |
fts_cache_t * fts_cache_create | ( | dict_table_t * | table | ) |
Create a FTS cache.
table owns the FTS cache
table | in: table owns the FTS cache |
|
static |
Free the FTS cache.
[in,out] | cache | to be freed |
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 |
fts_index_cache_t * fts_cache_index_cache_create | ( | dict_table_t * | table, |
dict_index_t * | index | ||
) |
Create an FTS index cache.
Create a FTS index cache.
table | in: table with FTS index |
index | in: FTS index |
void fts_cache_index_cache_remove | ( | dict_table_t * | table, |
dict_index_t * | index | ||
) |
Remove a FTS index cache.
[in] | table | table with FTS index |
[in] | index | FTS index |
void fts_cache_init | ( | fts_cache_t * | cache | ) |
Initialize FTS cache.
Initialize things in cache.
cache | in: cache to initialize |
void fts_cache_node_add_positions | ( | fts_cache_t * | cache, |
fts_node_t * | node, | ||
doc_id_t | doc_id, | ||
ib_vector_t * | positions | ||
) |
Add the given doc_id/word positions to the given node's ilist.
Add node positions.
cache | in: cache |
node | in: word node |
doc_id | in: doc id |
positions | in: fts_token_t::positions |
bool fts_check_cached_index | ( | dict_table_t * | table | ) |
Check indexes in the fts->indexes is also present in index cache and table->indexes list.
table | in: Table where indexes are dropped |
bool fts_check_common_tables_exist | ( | const dict_table_t * | table | ) |
Check if common tables already exist.
[in] | table | table with fts index |
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 |
|
static |
This function fetch the Doc ID from CONFIG table, and compare with the Doc ID supplied.
And store the larger one to the CONFIG table.
table | in: table |
doc_id_cmp | in: Doc ID to compare |
read_only | in: true if read the synced_doc_id only |
doc_id | out: larger document id after comparing "doc_id_cmp" to the one stored in CONFIG table |
trx | in: transaction in which the doc_id is retrieved and stored |
The given transaction is about to be committed; do whatever is necessary from the FTS system's POV.
trx | in: transaction |
|
static |
The given transaction is about to be committed; do whatever is necessary from the FTS system's POV.
ftt | in: FTS table to commit |
fts_t * fts_create | ( | dict_table_t * | table | ) |
Create an instance of fts_t.
table | in/out: table with FTS indexes |
bool fts_create_common_dd_tables | ( | const dict_table_t * | table | ) |
Update DD system table for auxiliary common tables for an FTS index.
[in] | table | dict table instance |
dberr_t fts_create_common_tables | ( | trx_t * | trx, |
const dict_table_t * | table, | ||
const char * | name, | ||
bool | skip_doc_id_index | ||
) |
Creates the common auxiliary tables needed for supporting an FTS index on the given table.
row_mysql_lock_data_dictionary must have been called before this. The following tables are created. CREATE TABLE $FTS_PREFIX_DELETED (doc_id BIGINT UNSIGNED, UNIQUE CLUSTERED INDEX on doc_id) CREATE TABLE $FTS_PREFIX_DELETED_CACHE (doc_id BIGINT UNSIGNED, UNIQUE CLUSTERED INDEX on doc_id) CREATE TABLE $FTS_PREFIX_BEING_DELETED (doc_id BIGINT UNSIGNED, UNIQUE CLUSTERED INDEX on doc_id) CREATE TABLE $FTS_PREFIX_BEING_DELETED_CACHE (doc_id BIGINT UNSIGNED, UNIQUE CLUSTERED INDEX on doc_id) CREATE TABLE $FTS_PREFIX_CONFIG (key CHAR(50), value CHAR(200), UNIQUE CLUSTERED INDEX on key)
[in,out] | trx | transaction |
[in] | table | table with FTS index |
[in] | name | table name normalized |
[in] | skip_doc_id_index | Skip index on doc id |
dberr_t fts_create_doc_id | ( | dict_table_t * | table, |
dtuple_t * | row, | ||
mem_heap_t * | heap | ||
) |
Create a new document id.
[in] | table | Row is of this table. |
[in,out] | row | Add doc id value to this row. This is the current row that is being inserted. |
[in] | heap | Memory heap on which the doc_id object will be created. |
|
static |
Create dict_table_t object for FTS Aux tables.
[in] | aux_table_name | FTS Aux table name |
[in] | table | table object of FTS Index |
[in] | n_cols | number of columns for FTS Aux table |
dberr_t fts_create_index_dd_tables | ( | dict_table_t * | table | ) |
Check if a table has FTS index needs to have its auxiliary index tables' metadata updated in DD.
[in,out] | table | table to check |
dberr_t fts_create_index_tables | ( | trx_t * | trx, |
dict_index_t * | index | ||
) |
Creates the column specific ancillary tables needed for supporting an FTS index on the given table.
row_mysql_lock_data_dictionary must have been called before this.
All FTS AUX Index tables have the following schema. CREATE TABLE $FTS_PREFIX_INDEX_[1-6]( word VARCHAR(FTS_MAX_WORD_LEN), first_doc_id INT NOT NULL, last_doc_id UNSIGNED NOT NULL, doc_count UNSIGNED INT NOT NULL, ilist VARBINARY NOT NULL, UNIQUE CLUSTERED INDEX ON (word, first_doc_id))
[in,out] | trx | transaction |
[in] | index | index instance |
dberr_t fts_create_index_tables_low | ( | trx_t * | trx, |
dict_index_t * | index, | ||
const char * | table_name, | ||
table_id_t | table_id | ||
) |
Create auxiliary index tables for an FTS index.
[in,out] | trx | transaction |
[in] | index | the index instance |
[in] | table_name | table name |
[in] | table_id | the table id |
|
static |
Function to create on FTS common table.
[in,out] | trx | InnoDB transaction |
[in] | table | Table that has FTS Index |
[in] | fts_table_name | FTS AUX table name |
[in] | fts_suffix | FTS AUX table suffix |
[in] | heap | heap |
|
static |
Update DD system table for auxiliary index tables for an FTS index.
[in] | index | the index instance |
|
static |
Creates one FTS auxiliary index table for an FTS index.
[in,out] | trx | transaction |
[in] | index | the index instance |
[in] | fts_table | fts_table structure |
[in] | heap | memory heap |
|
static |
Do commit-phase steps necessary for the deletion of a row.
ftt | in: FTS trx table |
row | in: row |
void fts_detach_aux_tables | ( | const dict_table_t * | table, |
bool | dict_locked | ||
) |
Allow all the auxiliary tables of specified base table to be evictable if they exist, if not exist just ignore.
[in] | table | InnoDB table object |
[in] | dict_locked | True if we have dict_sys mutex |
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 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 |
fts_doc_ids_t * fts_doc_ids_create | ( | void | ) |
Create a new fts_doc_ids_t.
void fts_doc_ids_free | ( | fts_doc_ids_t * | doc_ids | ) |
Free a fts_doc_ids_t.
in: doc_ids to free
void fts_doc_init | ( | fts_doc_t * | doc | ) |
Initialize a document.
in: doc to initialize
doc | in: doc to initialize |
|
static |
Drops FTS ancillary tables needed for supporting an FTS index on the given table.
row_mysql_lock_data_dictionary must have been called before this.
[in,out] | trx | transaction |
[in] | fts | fts instance |
[in,out] | aux_vec | fts aux table name vector |
|
static |
Drops the common ancillary tables needed for supporting an FTS index on the given table.
row_mysql_lock_data_dictionary must have been called before this.
[in,out] | trx | transaction |
[in,out] | fts_table | table with fts index |
[in,out] | aux_vec | fts table name vector |
bool fts_drop_dd_tables | ( | const aux_name_vec_t * | aux_vec, |
bool | file_per_table | ||
) |
Drop FTS AUX table DD table objects in vector.
[in] | aux_vec | aux table name vector |
[in] | file_per_table | whether file per table |
dberr_t fts_drop_index | ( | dict_table_t * | table, |
dict_index_t * | index, | ||
trx_t * | trx, | ||
aux_name_vec_t * | aux_vec, | ||
bool | adding_another | ||
) |
Drop auxiliary tables related to an FTS index.
[in] | table | Table where indexes are dropped |
[in] | index | Index to be dropped |
[in] | trx | Transaction for the drop |
[in,out] | aux_vec | Aux table name vector |
[in] | adding_another | Another FTS index is to be added as part of the same transaction |
dberr_t fts_drop_index_tables | ( | trx_t * | trx, |
dict_index_t * | index, | ||
aux_name_vec_t * | aux_vec | ||
) |
Since we do a horizontal split on the index table, we need to drop all the split tables.
[in] | trx | transaction |
[in] | index | fts index |
[out] | aux_vec | dropped table names vector |
|
static |
Drops a table.
If the table can't be found we return a SUCCESS code.
[in,out] | trx | transaction |
[in] | table_name | table to drop |
[in,out] | aux_vec | fts aux table name vector |
dberr_t fts_drop_tables | ( | trx_t * | trx, |
dict_table_t * | table, | ||
aux_name_vec_t * | aux_vec | ||
) |
Drops the ancillary tables needed for supporting an FTS index on a given table.
row_mysql_lock_data_dictionary must have been called before this.
[in,out] | trx | transaction |
[in] | table | table has the fts index |
[in,out] | aux_vec | fts aux table name vector |
dberr_t fts_empty_common_tables | ( | trx_t * | trx, |
dict_table_t * | table | ||
) |
Empty all common talbes.
[in,out] | trx | transaction |
[in] | table | dict table |
|
static |
Empty a common talbes.
[in,out] | trx | transaction |
[in] | fts_table | fts table |
|
static |
fetch and tokenize the document.
get_doc | in: FTS index's get_doc struct |
clust_index | in: cluster index |
pcur | in: cursor whose position has been stored |
offsets | in: offsets |
doc | out: fts doc to hold parsed documents |
|
static |
Fetch the data from tuple and tokenize the document.
[in] | get_doc | FTS index's get_doc struct |
[in] | tuple | tuple should be arranged in table schema order |
[out] | doc | fts doc to hold parsed documents. |
|
static |
Fetch callback that converts a textual document id to a binary value and stores it in the given place.
row | in: sel_node_t* |
user_arg | in: doc_id_t* to store doc_id in |
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 |
void fts_free | ( | dict_table_t * | table | ) |
Free the FTS resources.
in/out: table with FTS indexes
table | in/out: table with FTS indexes |
void fts_free_aux_names | ( | aux_name_vec_t * | aux_vec | ) |
Free FTS AUX table names in vector.
[in] | aux_vec | aux table name vector |
void fts_freeze_aux_tables | ( | const dict_table_t * | table | ) |
Freeze all auiliary tables to be not evictable if exist, with dict_mutex held.
[in] | table | InnoDB table object |
|
inlinestatic |
Get a character set based on precise type.
prtype | precise type |
doc_id_t fts_get_doc_id_from_rec | ( | dict_table_t * | table, |
const rec_t * | rec, | ||
const dict_index_t * | index, | ||
mem_heap_t * | heap | ||
) |
Extract the doc id from the record that belongs to index.
[in] | table | table |
[in] | rec | record contains FTS_DOC_ID |
[in] | index | index of rec |
[in] | heap | heap memory |
doc_id_t fts_get_doc_id_from_row | ( | dict_table_t * | table, |
dtuple_t * | row | ||
) |
Extract the doc id from the FTS hidden column.
table | in: table |
row | in: row whose FTS doc id we want to extract. |
|
static |
get_docs | in: Doc retrieval vector |
|
static |
Create the vector of fts_get_doc_t instances.
[in,out] | cache | fts cache |
|
inlinestatic |
Search the index specific cache for a particular FTS index.
cache | in: cache to search |
index | in: index to search for |
doc_id_t fts_get_max_doc_id | ( | dict_table_t * | table | ) |
Get maximum Doc ID in a table if index "FTS_DOC_ID_INDEX" exists.
table | in: user table |
dberr_t fts_get_next_doc_id | ( | const dict_table_t * | table, |
doc_id_t * | doc_id | ||
) |
Get the next available document id.
table | in: table |
doc_id | out: new document id |
ulint fts_get_rows_count | ( | fts_table_t * | fts_table | ) |
Fetch COUNT(*) from specified table.
fts_table | in: fts table to read |
|
inlinestatic |
Extract only the required flags from table->flags2 for FTS Aux tables.
[in] | flags2 | Table flags2 |
ulint fts_get_token_size | ( | const CHARSET_INFO * | cs, |
const char * | token, | ||
ulint | len | ||
) |
Get token char size by charset.
cs | in: Character set |
token | in: token |
len | in: token length |
|
static |
Check an index is in the table->indexes list.
table | in: Table |
index_check | in: index to be checked |
|
static |
Check an index is in the fts->cache->indexes list.
table | in: Table |
index | in: index to be checked |
|
static |
Initialize the index cache.
allocator | in: the allocator to use |
index_cache | in: index cache |
CHARSET_INFO * fts_index_get_charset | ( | dict_index_t * | index | ) |
Create an FTS index cache.
in: FTS index
index | in: FTS index |
|
static |
Write the default settings to the config table.
[in] | fts_table | fts table |
doc_id_t fts_init_doc_id | ( | const dict_table_t * | table | ) |
Get the initial Doc ID by consulting the CONFIG table.
table | in: table |
|
static |
Callback function when we initialize the FTS at the start up time.
It recovers the maximum Doc IDs presented in the current table.
row | in: sel_node_t* |
user_arg | in: fts cache |
bool fts_init_index | ( | dict_table_t * | table, |
bool | has_cache_lock | ||
) |
This function brings FTS index in sync when FTS index is first used.
There are documents that have not yet sync-ed to auxiliary tables from last server abnormally shutdown, we will need to bring such document into FTS cache before any further operations
table | in: Table with FTS |
has_cache_lock | in: Whether we already have cache lock |
|
static |
Callback function when we initialize the FTS at the start up time.
It recovers Doc IDs that have not sync-ed to the auxiliary table, and require to bring them back into FTS index.
When a nullptr is passed for trx, it means we will fetch the latest LOB (and no MVCC will be done).
row | in: sel_node_t* |
user_arg | in: fts cache |
bool fts_is_aux_table_name | ( | fts_aux_table_t * | table, |
const char * | name, | ||
ulint | len | ||
) |
Check if a table is an FTS auxiliary table name.
[out] | table | FTS table info |
[in] | name | Table name |
[in] | len | Length of table name |
|
static |
This function loads the default InnoDB stopword list.
stopword_info | in: stopword info |
bool fts_load_stopword | ( | const dict_table_t * | table, |
trx_t * | trx, | ||
const char * | global_stopword_table, | ||
const char * | session_stopword_table, | ||
bool | stopword_is_on, | ||
bool | reload | ||
) |
This function loads the stopword into the FTS cache.
This function loads specified stopword into FTS cache.
It also records/fetches stopword configuration to/from FTS configure table, depending on whether we are creating or reloading the FTS.
table | in: Table with FTS |
trx | in: Transactions |
global_stopword_table | in: Global stopword table name |
session_stopword_table | in: Session stopword table name |
stopword_is_on | in: Whether stopword option is turned on/off |
reload | in: Whether it is for reloading FTS table |
|
static |
Load user defined stopword from designated user table.
stopword_table_name | in: Stopword table name |
stopword_info | in: Stopword info |
dberr_t fts_lock_all_aux_tables | ( | THD * | thd, |
dict_table_t * | table | ||
) |
Lock all FTS AUX tables (for dropping table)
[in] | thd | thread locking the AUX table |
[in] | table | table has the fts index |
Lock all FTS index AUX tables (for dropping table)
[in] | thd | thread locking the AUX table |
[in] | fts | fts instance |
|
static |
Lock all FTS AUX COMMON tables (for dropping table)
[in] | thd | thread locking the AUX table |
[in,out] | fts_table | table with fts index |
dberr_t fts_lock_index_tables | ( | THD * | thd, |
dict_index_t * | index | ||
) |
Lock all FTS INDEX AUX tables (for dropping table)
[in] | thd | thread locking the AUX table |
[in] | index | fts index |
|
static |
Do commit-phase steps necessary for the modification of a row.
ftt | in: FTS trx table |
row | in: row |
|
static |
Process next token from document starting at the given position, i.e., add the token's start position to the token's list of positions.
[in,out] | doc | document to tokenize |
[out] | result | if provided, save result here |
[in] | start_pos | start position in text |
[in] | add_pos | add this position to all tokens from this tokenization |
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* |
|
static |
Callback function to read a single stopword value.
row | in: sel_node_t* |
user_arg | in: pointer to ib_vector_t |
|
static |
Callback function to read a single ulint column.
return always returns true
row | in: sel_node_t* |
user_arg | in: pointer to ulint |
dberr_t fts_rename_aux_tables | ( | dict_table_t * | table, |
const char * | new_name, | ||
trx_t * | trx, | ||
bool | replay | ||
) |
Rename auxiliary tables for all fts index for a table.
This(rename) is due to database name change
table | in: user Table |
new_name | in: new table name |
trx | in: transaction |
replay | in: Whether in replay stage |
|
static |
Rename a single auxiliary table due to database name change.
new_name | in: new parent tbl name |
fts_table_old_name | in: old aux tbl name |
trx | in: transaction |
replay | Whether in replay stage |
|
static |
recalibrate get_doc structure after index_cache in cache->indexes changed
cache | in: FTS index cache |
|
inlinestatic |
Take a FTS savepoint.
src | in: source savepoint |
dst | out: destination savepoint |
|
static |
Create a savepoint instance.
savepoints | out: InnoDB transaction |
name | in: savepoint name |
heap | in: heap |
|
inlinestatic |
Free an FTS savepoint instance.
savepoint | in: savepoint instance |
void fts_savepoint_laststmt_refresh | ( | trx_t * | trx | ) |
Refresh last statement savepoint.
in: transaction
trx | in: transaction |
|
inlinestatic |
Lookup a savepoint instance by name.
savepoints | in: savepoints |
name | in: savepoint name |
void fts_savepoint_release | ( | trx_t * | trx, |
const char * | name | ||
) |
Release the savepoint data identified by name.
All savepoints created after the named savepoint are kept.
trx | in: transaction |
name | in: savepoint name |
void fts_savepoint_rollback | ( | trx_t * | trx, |
const char * | name | ||
) |
Rollback to savepoint identified by name.
Rollback to and including savepoint identified by name.
trx | in: transaction |
name | in: savepoint name |
void fts_savepoint_rollback_last_stmt | ( | trx_t * | trx | ) |
Rollback to savepoint identified by name.
Rollback to and including savepoint identified by name.
trx | in: transaction |
void fts_savepoint_take | ( | fts_trx_t * | fts_trx, |
const char * | name | ||
) |
Take a FTS savepoint.
[in] | fts_trx | Fts transaction |
[in] | name | Savepoint name |
|
static |
Run SYNC on the table, i.e., write out data from the cache to the FTS auxiliary INDEX table and clear the cache at the end.
[in,out] | sync | sync state |
[in] | unlock_cache | whether unlock cache lock when write node |
[in] | wait | whether wait when a sync is in progress |
[in] | has_dict | whether has dict operation lock |
|
static |
Add rows to the DELETED_CACHE table.
sync | in: sync state |
doc_ids | in: doc ids to add |
|
static |
Begin Sync, create transaction, acquire locks, etc.
sync | in: sync state |
|
static |
Commit the SYNC, change state of processed doc ids etc.
[in,out] | sync | sync state |
|
static |
Run SYNC on the table, i.e., write out data from the index specific cache to the FTS aux INDEX table and FTS aux doc id stats table.
sync | in: sync state |
index_cache | in: index cache |
|
static |
Check if index cache has been synced completely.
[in,out] | index_cache | index cache |
|
static |
Reset synced flag in index cache when rollback.
[in,out] | index_cache | index cache |
|
static |
Rollback a sync operation.
sync | in: sync state |
dberr_t fts_sync_table | ( | dict_table_t * | table, |
bool | unlock_cache, | ||
bool | wait, | ||
bool | has_dict | ||
) |
Run SYNC on the table, i.e., write out data from the cache to the FTS auxiliary INDEX table and clear the cache at the end.
[in,out] | table | fts table |
[in] | unlock_cache | whether unlock cache when write node |
[in] | wait | whether wait for existing sync to finish |
[in] | has_dict | whether has dict operation lock |
|
static |
Write the words and ilist to disk.
[in,out] | trx | transaction |
[in] | index_cache | index cache |
[in] | unlock_cache | whether unlock cache when write node |
[in] | sync_start_time | Holds the timestamp of start of sync for deducing the length of sync time |
|
static |
FTS plugin parser 'myql_add_word' callback function for document tokenize.
Refer to 'MYSQL_FTPARSER_PARAM' for more detail.
|
static |
Parse a document using an external / user supplied parser.
|
static |
Tokenize a document.
[in,out] | doc | document to tokenize |
[out] | result | tokenization result |
[in] | parser | pluggable parser |
int fts_tokenize_document_internal | ( | MYSQL_FTPARSER_PARAM * | param, |
char * | doc, | ||
int | len | ||
) |
FTS plugin parser 'myql_parser' callback function for document tokenize.
FULLTEXT tokenizer internal in MYSQL_FTPARSER_SIMPLE_MODE.
Refer to 'MYSQL_FTPARSER_PARAM' for more detail.
param | in: parser parameter |
doc | in/out: document |
len | in: document length |
|
static |
Continue to tokenize a document.
[in,out] | doc | document to tokenize |
[in] | add_pos | add this position to all tokens from this tokenization |
[out] | result | tokenization result |
[in] | parser | pluggable parser |
|
static |
Find an existing word, or if not found, create one and return it.
cache | in: cache |
index_cache | in: index cache |
text | in: node text |
void fts_trx_add_op | ( | trx_t * | trx, |
dict_table_t * | table, | ||
doc_id_t | doc_id, | ||
fts_row_state | state, | ||
ib_vector_t * | fts_indexes | ||
) |
Notify the FTS system about an operation on an FTS-indexed table.
[in] | trx | Innodb transaction |
[in] | table | Table |
[in] | doc_id | Doc id |
[in] | state | State of the row |
[in] | fts_indexes | Fts indexes affected (null=all) |
Create an FTS trx.
[in,out] | trx | InnoDB Transaction |
void fts_trx_free | ( | fts_trx_t * | fts_trx | ) |
Free an FTS trx.
in, own: FTS trx
|
static |
Initialize the FTS trx instance.
trx | in: transaction |
table | in: FTS table instance |
savepoints | in: Savepoints |
|
static |
Calculate the new state of a row given the existing state and a new event.
old_state | in: existing state of row |
event | in: new event |
|
static |
Notify the FTS system about an operation on an FTS-indexed table.
ftt | in: FTS trx table |
doc_id | in: doc id |
state | in: state of the row |
fts_indexes | in: FTS indexes affected |
|
static |
Clone an FTS trx table.
ftt_src | in: FTS trx |
|
static |
Create an FTS trx table.
fts_trx | in: FTS trx |
table | in: table |
|
inlinestatic |
Free the modified rows of a table.
rows | in: rbt of rows to free |
|
static |
s_ftt | in: Transaction FTS table |
l_ftt | in: last stmt FTS table |
doc_id_t fts_update_doc_id | ( | dict_table_t * | table, |
upd_field_t * | ufield, | ||
doc_id_t * | next_doc_id | ||
) |
Add new fts doc id to the update vector.
[in] | table | the table that contains the FTS index. |
[in,out] | ufield | the fts doc id field in the update vector. No new memory is allocated for this in this function. |
[in,out] | next_doc_id | the fts doc id that has been added to the update vector. If 0, a new fts doc id is automatically generated. The memory provided for this argument will be used by the update vector. Ensure that the life time of this memory matches that of the update vector. |
void fts_update_next_doc_id | ( | trx_t * | trx, |
const dict_table_t * | table, | ||
const char * | table_name, | ||
doc_id_t | doc_id | ||
) |
Update the next and last Doc ID in the CONFIG table to be the input "doc_id" value (+ 1).
We would do so after each FTS index build or table truncate
trx | in/out: transaction |
table | in: table |
table_name | in: table name, or NULL |
doc_id | in: DOC ID to set |
|
static |
Update the last document id.
This function could create a new transaction to update the last document id.
This function could create a new transaction to update the last document id.
table | in: table |
table_name | in: table name, or NULL |
doc_id | in: last document id |
trx | in: update trx, or NULL |
dberr_t fts_upgrade_aux_tables | ( | dict_table_t * | table | ) |
Upgrade FTS AUX Tables.
The FTS common and aux tables are renamed because they have table_id in their name. We move table_ids by DICT_MAX_DD_TABLES offset. Aux tables are registered into DD after rename.
[in] | table | InnoDB table object |
|
inline |
During upgrade, tables are moved by DICT_MAX_DD_TABLES offset, remove this offset to get 5.7 fts aux table names.
[in] | table_id | 8.0 table id |
dberr_t fts_upgrade_rename | ( | const dict_table_t * | table, |
bool | rollback | ||
) |
Rename FTS AUX tablespace name from 8.0 format to 5.7 format.
This will be done on upgrade failure
[in] | table | parent table |
[in] | rollback | rollback the rename from 8.0 to 5.7 if true, rename to 5.7 format if false, mark the table as evictable |
|
static |
Rename old FTS common and aux tables with the new table_id.
[in] | old_name | old name of FTS AUX table |
[in] | new_name | new name of FTS AUX table |
[in] | rollback | if true, do the rename back else mark original AUX tables evictable |
|
static |
Rename old FTS common and aux tables with the new table_id.
[in] | old_name | old name of FTS AUX table |
[in] | new_name | new name of FTS AUX table |
CHARSET_INFO * fts_valid_stopword_table | ( | const char * | stopword_table_name | ) |
Check whether user supplied stopword table is of the right format.
Check whether user supplied stopword table exists and is of the right format.
Caller is responsible to hold dictionary locks.
stopword_table_name | in: Stopword table name |
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 |
|
static |
Release all resources help by the words rb tree e.g., the node ilist.
in: rb tree of words
words | in: rb tree of words |
dberr_t fts_write_node | ( | trx_t * | trx, |
que_t ** | graph, | ||
fts_table_t * | fts_table, | ||
fts_string_t * | word, | ||
fts_node_t * | node | ||
) |
Write out a single word's data as new entry/entries in the INDEX table.
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 |
|
static |
const char* fts_common_tables[] |
FTS auxiliary table suffixes that are common to all FT indexes.
It's defined in fts0fts.cc
const char* fts_common_tables_5_7[] |
FTS auxiliary table suffixes that are common to all FT indexes.
|
static |
Default config values for FTS indexes on a table.
|
staticconstexpr |
Time to sleep after DEADLOCK error before retrying operation in milliseconds.
const char* fts_default_stopword[] |
InnoDB default stopword list: There are different versions of stopwords, the stop words listed below comes from "Google Stopword" list.
Reference: http://meta.wikimedia.org/wiki/Stop_word_list/google_stop_word_list. The final version of InnoDB default stopword list is still pending for decision
const fts_index_selector_t fts_index_selector[] |
FTS auxiliary INDEX split intervals.
It's defined in fts/fts0fts.c.
const fts_index_selector_t fts_index_selector_5_7[] |
FTS auxiliary INDEX split intervals.
It's defined in fts/fts0fts.c.
char* fts_internal_tbl_name = nullptr |
variable to record innodb_fts_internal_tbl_name for information schema table INNODB_FTS_INSERTED etc.
Variable specifying the table that has Fulltext index to display its content through information schema table.
ulong fts_max_cache_size |
This is maximum FTS cache for each table and would be a configurable variable.
Variable specifying the maximum FTS cache size for each table.
|
static |
ulong fts_max_token_size |
Variable specifying the maximum FTS max token size.
ulong fts_max_total_cache_size |
Variable specifying the total memory allocated for FTS cache.
ulong fts_min_token_size |
Variable specifying the minimum FTS max token size.
bool fts_need_sync = false |
Whether the total memory used for FTS cache is exhausted, and we will need a sync to free some memory.
const char* FTS_PREFIX = "fts_" |
FTS auxiliary table prefix that are common to all FT indexes.
const char* FTS_PREFIX_5_7 = "FTS_" |
FTS auxiliary table prefix that are common to all FT indexes.
ulong fts_result_cache_limit |
This is FTS result cache limit for each query and would be a configurable variable.
Variable specifying the FTS result cache limit for each query.
const char* FTS_SUFFIX_BEING_DELETED = fts_common_tables[0] |
const char* FTS_SUFFIX_BEING_DELETED_CACHE = fts_common_tables[1] |
const char* FTS_SUFFIX_CONFIG = fts_common_tables[2] |
const char* FTS_SUFFIX_CONFIG_5_7 = fts_common_tables_5_7[2] |
const char* FTS_SUFFIX_DELETED = fts_common_tables[3] |
const char* FTS_SUFFIX_DELETED_CACHE = fts_common_tables[4] |
|
static |