MySQL 9.1.0
Source Code Documentation
|
Full text search header file. More...
#include "ha_prototypes.h"
#include "data0type.h"
#include "data0types.h"
#include "dict0types.h"
#include "ft_global.h"
#include "hash0hash.h"
#include "mem0mem.h"
#include "mysql/plugin_ftparser.h"
#include "que0types.h"
#include "rem0types.h"
#include "row0types.h"
#include "trx0types.h"
#include "ut0rbt.h"
#include "ut0vec.h"
#include "ut0wqueue.h"
Go to the source code of this file.
Classes | |
struct | aux_name_vec_t |
Structure to manage FTS AUX table name and MDL during its drop. More... | |
struct | fts_trx_t |
Information about changes in a single transaction affecting the FTS system. More... | |
struct | fts_savepoint_t |
Information required for transaction savepoint handling. More... | |
struct | fts_trx_table_t |
Information about changed rows in a transaction for a single table. More... | |
struct | fts_trx_row_t |
Information about one changed row in a transaction. More... | |
struct | fts_doc_ids_t |
List of document ids that were added during a transaction. More... | |
struct | fts_string_t |
An UTF-16 ro UTF-8 string. More... | |
struct | fts_ranking_t |
Query ranked doc ids. More... | |
struct | fts_result_t |
Query result. More... | |
struct | fts_table_t |
This is used to generate the FTS auxiliary table name, we need the table id and the index id to generate the column specific FTS auxiliary table name. More... | |
class | fts_t |
The state of the FTS sub system. More... | |
struct | fts_aux_table_t |
For storing table info when checking for orphaned tables. More... | |
Macros | |
#define | FTS_NULL_DOC_ID 0 |
"NULL" value of a document id. More... | |
#define | FTS_DOC_ID_COL_NAME "FTS_DOC_ID" |
FTS hidden column that is used to map to and from the row. More... | |
#define | FTS_DOC_ID_INDEX_NAME "FTS_DOC_ID_INDEX" |
The name of the index created by FTS. More... | |
#define | FTS_DOC_ID_INDEX_NAME_LEN 16 |
#define | FTS_DOC_ID_LEN 8 |
Doc ID is a 8 byte value. More... | |
#define | FTS_NUM_FIELDS_SORT 3 |
The number of fields to sort when we build FT index with FIC. More... | |
#define | MAX_DOC_ID_OPT_VAL 1073741824 |
Maximum number of rows in a table, smaller than which, we will optimize using a 4 byte Doc ID for FIC merge sort to reduce sort size. More... | |
#define | FTS_DOC_ID_FORMAT IB_ID_FMT |
doc_id_t printf format More... | |
#define | fts_write_doc_id(d, s) mach_write_to_8(d, s) |
Convert document id to the InnoDB (BIG ENDIAN) storage format. More... | |
#define | fts_read_doc_id(s) mach_read_from_8(s) |
Read a document id to internal format. More... | |
#define | fts_bind_doc_id(i, n, v) pars_info_bind_int8_literal(i, n, v) |
Bind the doc id to a variable. More... | |
#define | FTS_NL 0 |
Defines for FTS query mode, they have the same values as those defined in mysql file ft_global.h. More... | |
#define | FTS_BOOL 1 |
#define | FTS_SORTED 2 |
#define | FTS_EXPAND 4 |
#define | FTS_NO_RANKING 8 |
#define | FTS_PROXIMITY 16 |
#define | FTS_PHRASE 32 |
#define | FTS_OPT_RANKING 64 |
#define | FTS_INDEX_TABLE_IND_NAME "FTS_INDEX_TABLE_IND" |
#define | FTS_COMMON_TABLE_IND_NAME "FTS_COMMON_TABLE_IND" |
#define | FTS_OPTIMIZE_THRESHOLD 10000000 |
Threshold where our optimize thread automatically kicks in. More... | |
#define | FTS_DOC_ID_MAX_STEP 65535 |
Threshold to avoid exhausting of doc ids. More... | |
#define | FTS_MAX_WORD_LEN HA_FT_MAXBYTELEN |
Maximum possible Fulltext word length. More... | |
#define | FTS_MAX_WORD_LEN_IN_CHAR HA_FT_MAXCHARLEN |
Maximum possible Fulltext word length (in characters) More... | |
#define | FTS_DELETED_TABLE_NUM_COLS 1 |
Number of columns in FTS AUX Tables. More... | |
#define | FTS_CONFIG_TABLE_NUM_COLS 2 |
#define | FTS_AUX_INDEX_TABLE_NUM_COLS 5 |
#define | FTS_DELETED_TABLE_COL_LEN 8 |
DELETED_TABLE(doc_id BIGINT UNSIGNED) More... | |
#define | FTS_CONFIG_TABLE_KEY_COL_LEN 50 |
CONFIG_TABLE(key CHAR(50), value CHAR(200)) More... | |
#define | FTS_CONFIG_TABLE_VALUE_COL_LEN 200 |
#define | FTS_INDEX_WORD_LEN FTS_MAX_WORD_LEN |
#define | FTS_INDEX_FIRST_DOC_ID_LEN 8 |
#define | FTS_INDEX_LAST_DOC_ID_LEN 8 |
#define | FTS_INDEX_DOC_COUNT_LEN 4 |
#define | FTS_INDEX_ILIST_LEN 0 |
#define | FTS_MAX_NESTED_EXP 31 |
#define | FTS_INIT_FTS_TABLE(fts_table, m_suffix, m_type, m_table) |
Initialize the "fts_table" for internal query into FTS auxiliary tables. More... | |
#define | FTS_INIT_INDEX_TABLE(fts_table, m_suffix, m_type, m_index) |
#define | STOPWORD_NOT_INIT 0x1 |
status bits for fts_stopword_t status field. More... | |
#define | STOPWORD_OFF 0x2 |
#define | STOPWORD_FROM_DEFAULT 0x4 |
#define | STOPWORD_USER_TABLE 0x8 |
#define | fts_que_graph_free(graph) |
Typedefs | |
typedef uint64_t | doc_id_t |
Document id type. More... | |
typedef float | fts_rank_t |
FTS rank type, which will be between 0 . More... | |
typedef unsigned short | ib_uc_t |
Since MySQL's character set support for Unicode is woefully inadequate (it supports basic operations like isalpha etc. More... | |
typedef enum fts_status | fts_status_t |
Enumerations | |
enum | fts_row_state { FTS_INSERT = 0 , FTS_MODIFY , FTS_DELETE , FTS_NOTHING , FTS_INVALID } |
Type of a row during a transaction. More... | |
enum | fts_table_type_t { FTS_INDEX_TABLE , FTS_COMMON_TABLE , FTS_OBSOLETED_TABLE } |
The FTS table types. More... | |
enum | fts_status { BG_THREAD_STOP = 1 , BG_THREAD_READY = 2 , ADD_THREAD_STARTED = 4 , ADDED_TABLE_SYNCED = 8 } |
Functions | |
fts_cache_t * | fts_cache_create (dict_table_t *table) |
Create a FTS cache. More... | |
fts_index_cache_t * | fts_cache_index_cache_create (dict_table_t *table, dict_index_t *index) |
Create a FTS index cache. More... | |
void | fts_cache_index_cache_remove (dict_table_t *table, dict_index_t *index) |
Remove a FTS index cache. 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... | |
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_create_doc_id (dict_table_t *table, dtuple_t *row, mem_heap_t *heap) |
Create a new document id. 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 *doc_ids) |
Free a fts_doc_ids_t. 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... | |
void | fts_trx_free (fts_trx_t *fts_trx) |
Free an FTS trx. 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... | |
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... | |
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... | |
void | fts_add_doc_id_column (dict_table_t *table, mem_heap_t *heap) |
Add the FTS document id hidden column. 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... | |
dberr_t | fts_lock_all_aux_tables (THD *thd, dict_table_t *table) |
Lock all FTS AUX tables (for dropping table) 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... | |
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... | |
dberr_t | fts_query (trx_t *trx, dict_index_t *index, uint flags, const byte *query_str, ulint query_len, fts_result_t **result, ulonglong limit) |
FTS Query entry point. More... | |
float | fts_retrieve_ranking (fts_result_t *result, doc_id_t doc_id) |
Retrieve the FTS Relevance Ranking result for doc with doc_id. More... | |
void | fts_query_sort_result_on_rank (fts_result_t *result) |
FTS Query sort result, returned by fts_query() on fts_ranking_t::rank. More... | |
void | fts_query_free_result (fts_result_t *result) |
FTS Query free result, returned by fts_query(). 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... | |
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... | |
void | fts_startup (void) |
FTS initialize. 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... | |
dberr_t | fts_optimize_table (dict_table_t *table) |
Run OPTIMIZE on the given table. More... | |
void | fts_optimize_init (void) |
Startup the optimize thread and create the work queue. 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... | |
dberr_t | fts_empty_common_tables (trx_t *trx, dict_table_t *table) |
Empty all common talbes. More... | |
void | fts_optimize_remove_table (dict_table_t *table) |
Remove the table from the OPTIMIZER's list. More... | |
void | fts_optimize_shutdown () |
Shutdown fts optimize thread. More... | |
void | fts_optimize_request_sync_table (dict_table_t *table) |
Send sync fts cache for the table. More... | |
void | fts_savepoint_take (fts_trx_t *fts_trx, const char *name) |
Take a FTS savepoint. More... | |
void | fts_savepoint_laststmt_refresh (trx_t *trx) |
Refresh last statement savepoint. More... | |
void | fts_savepoint_release (trx_t *trx, const char *name) |
Release the savepoint data identified by name. More... | |
void | fts_cache_clear (fts_cache_t *cache) |
Clear cache. More... | |
void | fts_cache_init (fts_cache_t *cache) |
Initialize things in cache. More... | |
void | fts_savepoint_rollback (trx_t *trx, const char *name) |
Rollback to and including savepoint identified by name. More... | |
void | fts_savepoint_rollback_last_stmt (trx_t *trx) |
Rollback to and including savepoint identified by name. More... | |
char * | fts_get_parent_table_name (const char *aux_table_name, ulint aux_table_len) |
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... | |
CHARSET_INFO * | fts_index_get_charset (dict_index_t *index) |
Create an FTS index cache. More... | |
doc_id_t | fts_init_doc_id (const dict_table_t *table) |
Get the initial Doc ID by consulting the CONFIG table. More... | |
int | innobase_fts_text_cmp (const void *cs, const void *p1, const void *p2) |
Compare two character string according to their charset. More... | |
size_t | innobase_fts_casedn_str (CHARSET_INFO *cs, char *src, size_t src_len, char *dst, size_t dst_len) |
Makes all characters in a string lower case. More... | |
int | innobase_fts_text_cmp_prefix (const void *cs, const void *p1, const void *p2) |
Compare two character string according to their charset. More... | |
ulint | innobase_mysql_fts_get_token (CHARSET_INFO *charset, const byte *start, const byte *end, fts_string_t *token) |
Get the next token from the given string and store it in *token. More... | |
bool | innobase_fts_drop_dd_table (const char *name, bool file_per_table) |
Drop dd table & tablespace for fts aux table. 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) |
FULLTEXT tokenizer internal in MYSQL_FTPARSER_SIMPLE_MODE. More... | |
ulint | fts_get_rows_count (fts_table_t *fts_table) |
Fetch COUNT(*) from specified table. 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... | |
CHARSET_INFO * | fts_valid_stopword_table (const char *stopword_table_name) |
Check whether user supplied stopword table exists and 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 specified stopword into FTS cache. More... | |
dberr_t | fts_table_fetch_doc_ids (trx_t *trx, fts_table_t *fts_table, fts_doc_ids_t *doc_ids) |
Read the rows from the FTS index. 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... | |
void | fts_add_index (dict_index_t *index, dict_table_t *table) |
Add a newly create index in FTS cache. 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=false) |
Drop auxiliary tables related to an FTS index. 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... | |
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... | |
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... | |
fts_trx_t * | fts_trx_create (trx_t *trx) |
Create an FTS trx. 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... | |
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... | |
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_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 | |
constexpr size_t | FTS_NUM_AUX_INDEX = 6 |
The number of FTS index partitions for a fulltext index. More... | |
constexpr size_t | FTS_NUM_AUX_COMMON = 5 |
The number of FTS AUX common table for a fulltext index. More... | |
const char * | FTS_PREFIX |
FTS auxiliary table prefix that are common to all FT indexes. More... | |
const char * | FTS_SUFFIX_BEING_DELETED |
const char * | FTS_SUFFIX_BEING_DELETED_CACHE |
const char * | FTS_SUFFIX_CONFIG |
const char * | FTS_SUFFIX_DELETED |
const char * | FTS_SUFFIX_DELETED_CACHE |
const char * | FTS_PREFIX_5_7 |
FTS auxiliary table prefix that are common to all FT indexes. More... | |
const char * | FTS_SUFFIX_CONFIG_5_7 |
ulong | fts_num_word_optimize |
Variable specifying the number of word to optimize for each optimize table call. More... | |
bool | fts_enable_diag_print |
Variable specifying whether we do additional FTS diagnostic printout in the log. 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... | |
ulong | fts_max_cache_size |
Variable specifying the maximum FTS cache size for each table. More... | |
ulong | fts_max_total_cache_size |
Variable specifying the total memory allocated for FTS cache. More... | |
ulong | fts_result_cache_limit |
Variable specifying the FTS result cache limit for each query. 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... | |
bool | fts_need_sync |
Whether the total memory used for FTS cache is exhausted, and we will need a sync to free some memory. More... | |
char * | fts_internal_tbl_name |
Variable specifying the table that has Fulltext index to display its content through information schema table. More... | |
Full text search header file.
Created 2011/09/02 Sunny Bains
#define FTS_AUX_INDEX_TABLE_NUM_COLS 5 |
#define fts_bind_doc_id | ( | i, | |
n, | |||
v | |||
) | pars_info_bind_int8_literal(i, n, v) |
Bind the doc id to a variable.
#define FTS_BOOL 1 |
#define FTS_COMMON_TABLE_IND_NAME "FTS_COMMON_TABLE_IND" |
#define FTS_CONFIG_TABLE_KEY_COL_LEN 50 |
CONFIG_TABLE(key CHAR(50), value CHAR(200))
#define FTS_CONFIG_TABLE_NUM_COLS 2 |
#define FTS_CONFIG_TABLE_VALUE_COL_LEN 200 |
#define FTS_DELETED_TABLE_COL_LEN 8 |
DELETED_TABLE(doc_id BIGINT UNSIGNED)
#define FTS_DELETED_TABLE_NUM_COLS 1 |
Number of columns in FTS AUX Tables.
#define FTS_DOC_ID_COL_NAME "FTS_DOC_ID" |
FTS hidden column that is used to map to and from the row.
#define FTS_DOC_ID_FORMAT IB_ID_FMT |
doc_id_t printf format
#define FTS_DOC_ID_INDEX_NAME "FTS_DOC_ID_INDEX" |
The name of the index created by FTS.
#define FTS_DOC_ID_INDEX_NAME_LEN 16 |
#define FTS_DOC_ID_LEN 8 |
Doc ID is a 8 byte value.
#define FTS_DOC_ID_MAX_STEP 65535 |
Threshold to avoid exhausting of doc ids.
Consecutive doc id difference should not exceed FTS_DOC_ID_MAX_STEP
#define FTS_EXPAND 4 |
#define FTS_INDEX_DOC_COUNT_LEN 4 |
#define FTS_INDEX_FIRST_DOC_ID_LEN 8 |
#define FTS_INDEX_ILIST_LEN 0 |
#define FTS_INDEX_LAST_DOC_ID_LEN 8 |
#define FTS_INDEX_TABLE_IND_NAME "FTS_INDEX_TABLE_IND" |
#define FTS_INDEX_WORD_LEN FTS_MAX_WORD_LEN |
#define FTS_INIT_FTS_TABLE | ( | fts_table, | |
m_suffix, | |||
m_type, | |||
m_table | |||
) |
Initialize the "fts_table" for internal query into FTS auxiliary tables.
#define FTS_INIT_INDEX_TABLE | ( | fts_table, | |
m_suffix, | |||
m_type, | |||
m_index | |||
) |
#define FTS_MAX_NESTED_EXP 31 |
#define FTS_MAX_WORD_LEN HA_FT_MAXBYTELEN |
Maximum possible Fulltext word length.
#define FTS_MAX_WORD_LEN_IN_CHAR HA_FT_MAXCHARLEN |
Maximum possible Fulltext word length (in characters)
#define FTS_NL 0 |
Defines for FTS query mode, they have the same values as those defined in mysql file ft_global.h.
#define FTS_NO_RANKING 8 |
#define FTS_NULL_DOC_ID 0 |
"NULL" value of a document id.
#define FTS_NUM_FIELDS_SORT 3 |
The number of fields to sort when we build FT index with FIC.
Three fields are sort: (word, doc_id, position)
#define FTS_OPT_RANKING 64 |
#define FTS_OPTIMIZE_THRESHOLD 10000000 |
Threshold where our optimize thread automatically kicks in.
#define FTS_PHRASE 32 |
#define FTS_PROXIMITY 16 |
#define fts_que_graph_free | ( | graph | ) |
#define fts_read_doc_id | ( | s | ) | mach_read_from_8(s) |
Read a document id to internal format.
#define FTS_SORTED 2 |
#define fts_write_doc_id | ( | d, | |
s | |||
) | mach_write_to_8(d, s) |
Convert document id to the InnoDB (BIG ENDIAN) storage format.
#define MAX_DOC_ID_OPT_VAL 1073741824 |
Maximum number of rows in a table, smaller than which, we will optimize using a 4 byte Doc ID for FIC merge sort to reduce sort size.
#define STOPWORD_FROM_DEFAULT 0x4 |
#define STOPWORD_NOT_INIT 0x1 |
status bits for fts_stopword_t status field.
#define STOPWORD_OFF 0x2 |
#define STOPWORD_USER_TABLE 0x8 |
typedef uint64_t doc_id_t |
Document id type.
typedef float fts_rank_t |
FTS rank type, which will be between 0 .
. 1 inclusive
typedef enum fts_status fts_status_t |
typedef unsigned short ib_uc_t |
Since MySQL's character set support for Unicode is woefully inadequate (it supports basic operations like isalpha etc.
only for 8-bit characters), we have to implement our own. We use UTF-16 without surrogate processing as our in-memory format. This typedef is a single such character.
enum fts_row_state |
Type of a row during a transaction.
FTS_NOTHING means the row can be forgotten from the FTS system's POV, FTS_INVALID is an internal value used to mark invalid states.
NOTE: Do not change the order or value of these, fts_trx_row_get_new_state depends on them being exactly as they are.
Enumerator | |
---|---|
FTS_INSERT | |
FTS_MODIFY | |
FTS_DELETE | |
FTS_NOTHING | |
FTS_INVALID |
enum fts_status |
enum fts_table_type_t |
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 in FTS cache.
table
Add a newly create index in FTS cache.
index | FTS index to be added |
table | table |
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 |
fts_index_cache_t * fts_cache_index_cache_create | ( | dict_table_t * | table, |
dict_index_t * | index | ||
) |
Create a 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 things in cache.
in: cache
Initialize things in cache.
cache | in: cache to initialize |
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 |
The given transaction is about to be committed; do whatever is necessary from the FTS system's POV.
trx | in: transaction |
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. |
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 |
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 |
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
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 |
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 |
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 |
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.
in: row whose FTS doc id we want to extract.
table | in: table |
row | in: row whose FTS doc id we want to extract. |
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.
This function creates a new transaction to generate the document id.
table | in: table |
doc_id | out: new document id |
char * fts_get_parent_table_name | ( | const char * | aux_table_name, |
ulint | aux_table_len | ||
) |
ulint fts_get_rows_count | ( | fts_table_t * | fts_table | ) |
Fetch COUNT(*) from specified table.
fts_table | in: fts table to read |
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 |
CHARSET_INFO * fts_index_get_charset | ( | dict_index_t * | index | ) |
Create an FTS index cache.
in: FTS index
index | in: FTS index |
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 |
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
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 |
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 |
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 specified stopword into 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 |
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 |
void fts_optimize_init | ( | void | ) |
Startup the optimize thread and create the work queue.
void fts_optimize_remove_table | ( | dict_table_t * | table | ) |
Remove the table from the OPTIMIZER's list.
We do wait for acknowledgement from the consumer of the message. in: table to remove
We do wait for acknowledgement from the consumer of the message.
table | in: table to remove |
void fts_optimize_request_sync_table | ( | dict_table_t * | table | ) |
Send sync fts cache for the table.
[in] | table | table to sync |
void fts_optimize_shutdown | ( | ) |
Shutdown fts optimize thread.
dberr_t fts_optimize_table | ( | dict_table_t * | table | ) |
Run OPTIMIZE on the given table.
table | in: table to optimize |
dberr_t fts_query | ( | trx_t * | trx, |
dict_index_t * | index, | ||
uint | flags, | ||
const byte * | query_str, | ||
ulint | query_len, | ||
fts_result_t ** | result, | ||
ulonglong | limit | ||
) |
FTS Query entry point.
[in] | trx | transaction |
[in] | index | fts index to search |
[in] | flags | FTS search mode |
[in] | query_str | FTS query |
[in] | query_len | FTS query string len in bytes |
[in,out] | result | result doc ids |
[in] | limit | limit value |
void fts_query_free_result | ( | fts_result_t * | result | ) |
FTS Query free result, returned by fts_query().
in: result instance to free.
result | in: result instance to free. |
void fts_query_sort_result_on_rank | ( | fts_result_t * | result | ) |
FTS Query sort result, returned by fts_query() on fts_ranking_t::rank.
out: result instance to sort.
result | out: result instance to sort. |
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 |
float fts_retrieve_ranking | ( | fts_result_t * | result, |
doc_id_t | doc_id | ||
) |
Retrieve the FTS Relevance Ranking result for doc with doc_id.
result | in: FTS result structure |
doc_id | in: doc_id of the item to retrieve |
void fts_savepoint_laststmt_refresh | ( | trx_t * | trx | ) |
Refresh last statement savepoint.
in: transaction
trx | in: transaction |
void fts_savepoint_release | ( | trx_t * | trx, |
const char * | name | ||
) |
Release the savepoint data identified by name.
in: savepoint 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 and including savepoint identified by name.
in: savepoint 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 and including savepoint identified by name.
in: transaction
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 |
void fts_startup | ( | void | ) |
FTS initialize.
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 |
dberr_t fts_table_fetch_doc_ids | ( | trx_t * | trx, |
fts_table_t * | fts_table, | ||
fts_doc_ids_t * | doc_ids | ||
) |
Read the rows from the FTS index.
Read the rows from the FTS index.
trx | in: transaction |
fts_table | in: table |
doc_ids | in: For collecting doc ids |
int fts_tokenize_document_internal | ( | MYSQL_FTPARSER_PARAM * | param, |
char * | doc, | ||
int | len | ||
) |
FULLTEXT tokenizer internal in MYSQL_FTPARSER_SIMPLE_MODE.
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 |
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
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 in: DOC ID to set
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 |
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 |
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 |
CHARSET_INFO * fts_valid_stopword_table | ( | const char * | stopword_table_name | ) |
Check whether user supplied stopword table exists and 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 |
size_t innobase_fts_casedn_str | ( | CHARSET_INFO * | cs, |
char * | src, | ||
size_t | src_len, | ||
char * | dst, | ||
size_t | dst_len | ||
) |
Makes all characters in a string lower case.
[in] | cs | Character set |
[in] | src | String to put in lower case |
[in] | src_len | Input string length |
[in] | dst | Buffer for result string |
[in] | dst_len | Buffer size |
bool innobase_fts_drop_dd_table | ( | const char * | name, |
bool | file_per_table | ||
) |
Drop dd table & tablespace for fts aux table.
[in] | name | table name |
[in] | file_per_table | flag whether use file per table |
int innobase_fts_text_cmp | ( | const void * | cs, |
const void * | p1, | ||
const void * | p2 | ||
) |
Compare two character string according to their charset.
[in] | cs | Character set |
[in] | p1 | Key |
[in] | p2 | Node |
int innobase_fts_text_cmp_prefix | ( | const void * | cs, |
const void * | p1, | ||
const void * | p2 | ||
) |
Compare two character string according to their charset.
[in] | cs | Character set |
[in] | p1 | Key |
[in] | p2 | Node |
ulint innobase_mysql_fts_get_token | ( | CHARSET_INFO * | cs, |
const byte * | start, | ||
const byte * | end, | ||
fts_string_t * | token | ||
) |
Get the next token from the given string and store it in *token.
out: token's text
It is mostly copied from MyISAM's doc parsing function ft_simple_get_word()
cs | in: Character set |
start | in: start of text |
end | in: one character past end of text |
token | out: token's text |
|
extern |
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
|
extern |
Variable specifying whether we do additional FTS diagnostic printout in the log.
|
extern |
Variable specifying the table that has Fulltext index to display its content through information schema table.
Variable specifying the table that has Fulltext index to display its content through information schema table.
|
extern |
Variable specifying the maximum FTS cache size for each table.
Variable specifying the maximum FTS cache size for each table.
|
extern |
Variable specifying the maximum FTS max token size.
|
extern |
Variable specifying the total memory allocated for FTS cache.
|
extern |
Variable specifying the minimum FTS max token size.
|
extern |
Whether the total memory used for FTS cache is exhausted, and we will need a sync to free some memory.
|
constexpr |
The number of FTS AUX common table for a fulltext index.
|
constexpr |
The number of FTS index partitions for a fulltext index.
|
extern |
Variable specifying the number of word to optimize for each optimize table call.
Variable specifying the number of word to optimize for each optimize table call.
|
extern |
FTS auxiliary table prefix that are common to all FT indexes.
|
extern |
FTS auxiliary table prefix that are common to all FT indexes.
|
extern |
Variable specifying the FTS result cache limit for each query.
Variable specifying the FTS result cache limit for each query.
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |
|
extern |