MySQL 8.0.31
Source Code Documentation
fts0fts.h
Go to the documentation of this file.
1/*****************************************************************************
2
3Copyright (c) 2006, 2022, Oracle and/or its affiliates.
4
5This program is free software; you can redistribute it and/or modify it under
6the terms of the GNU General Public License, version 2.0, as published by the
7Free Software Foundation.
8
9This program is also distributed with certain software (including but not
10limited to OpenSSL) that is licensed under separate terms, as designated in a
11particular file or component or in included license documentation. The authors
12of MySQL hereby grant you an additional permission to link the program and
13your derivative works with the separately licensed software that they have
14included with MySQL.
15
16This program is distributed in the hope that it will be useful, but WITHOUT
17ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
19for more details.
20
21You should have received a copy of the GNU General Public License along with
22this program; if not, write to the Free Software Foundation, Inc.,
2351 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24
25*****************************************************************************/
26
27/** @file include/fts0fts.h
28 Full text search header file
29
30 Created 2011/09/02 Sunny Bains
31 ***********************************************************************/
32
33#ifndef fts0fts_h
34#define fts0fts_h
35
36#include "ha_prototypes.h"
37
38#include "data0type.h"
39#include "data0types.h"
40#include "dict0types.h"
41#include "ft_global.h"
42#include "hash0hash.h"
43#include "mem0mem.h"
45#include "que0types.h"
46#include "rem0types.h"
47#include "row0types.h"
48#include "trx0types.h"
49#include "ut0rbt.h"
50#include "ut0vec.h"
51#include "ut0wqueue.h"
52
53/** "NULL" value of a document id. */
54#define FTS_NULL_DOC_ID 0
55
56/** FTS hidden column that is used to map to and from the row */
57#define FTS_DOC_ID_COL_NAME "FTS_DOC_ID"
58
59/** The name of the index created by FTS */
60#define FTS_DOC_ID_INDEX_NAME "FTS_DOC_ID_INDEX"
61
62#define FTS_DOC_ID_INDEX_NAME_LEN 16
63
64/** Doc ID is a 8 byte value */
65#define FTS_DOC_ID_LEN 8
66
67/** The number of fields to sort when we build FT index with
68FIC. Three fields are sort: (word, doc_id, position) */
69#define FTS_NUM_FIELDS_SORT 3
70
71/** Maximum number of rows in a table, smaller than which, we will
72optimize using a 4 byte Doc ID for FIC merge sort to reduce sort size */
73#define MAX_DOC_ID_OPT_VAL 1073741824
74
75/** Document id type. */
76typedef uint64_t doc_id_t;
77
78/** doc_id_t printf format */
79#define FTS_DOC_ID_FORMAT IB_ID_FMT
80
81/** Convert document id to the InnoDB (BIG ENDIAN) storage format. */
82#define fts_write_doc_id(d, s) mach_write_to_8(d, s)
83
84/** Read a document id to internal format. */
85#define fts_read_doc_id(s) mach_read_from_8(s)
86
87/** Bind the doc id to a variable */
88#define fts_bind_doc_id(i, n, v) pars_info_bind_int8_literal(i, n, v)
89
90/** Defines for FTS query mode, they have the same values as
91those defined in mysql file ft_global.h */
92#define FTS_NL 0
93#define FTS_BOOL 1
94#define FTS_SORTED 2
95#define FTS_EXPAND 4
96#define FTS_NO_RANKING 8
97#define FTS_PROXIMITY 16
98#define FTS_PHRASE 32
99#define FTS_OPT_RANKING 64
100
101#define FTS_INDEX_TABLE_IND_NAME "FTS_INDEX_TABLE_IND"
102#define FTS_COMMON_TABLE_IND_NAME "FTS_COMMON_TABLE_IND"
103
104/** The number of FTS index partitions for a fulltext index. */
105constexpr size_t FTS_NUM_AUX_INDEX = 6;
106
107/** The number of FTS AUX common table for a fulltext index. */
108constexpr size_t FTS_NUM_AUX_COMMON = 5;
109
110/** Threshold where our optimize thread automatically kicks in */
111#define FTS_OPTIMIZE_THRESHOLD 10000000
112
113/** Threshold to avoid exhausting of doc ids. Consecutive doc id difference
114should not exceed FTS_DOC_ID_MAX_STEP */
115#define FTS_DOC_ID_MAX_STEP 65535
116
117/** Maximum possible Fulltext word length */
118#define FTS_MAX_WORD_LEN HA_FT_MAXBYTELEN
119
120/** Maximum possible Fulltext word length (in characters) */
121#define FTS_MAX_WORD_LEN_IN_CHAR HA_FT_MAXCHARLEN
122
123/** Number of columns in FTS AUX Tables */
124#define FTS_DELETED_TABLE_NUM_COLS 1
125#define FTS_CONFIG_TABLE_NUM_COLS 2
126#define FTS_AUX_INDEX_TABLE_NUM_COLS 5
127
128/** DELETED_TABLE(doc_id BIGINT UNSIGNED) */
129#define FTS_DELETED_TABLE_COL_LEN 8
130/** CONFIG_TABLE(key CHAR(50), value CHAR(200)) */
131#define FTS_CONFIG_TABLE_KEY_COL_LEN 50
132#define FTS_CONFIG_TABLE_VALUE_COL_LEN 200
133
134#define FTS_INDEX_WORD_LEN FTS_MAX_WORD_LEN
135#define FTS_INDEX_FIRST_DOC_ID_LEN 8
136#define FTS_INDEX_LAST_DOC_ID_LEN 8
137#define FTS_INDEX_DOC_COUNT_LEN 4
138/* BLOB COLUMN, 0 means VARIABLE SIZE */
139#define FTS_INDEX_ILIST_LEN 0
140/* Maximum nested expression in fulltext binary search string */
141#define FTS_MAX_NESTED_EXP 31
142
143extern const char *FTS_PREFIX;
144extern const char *FTS_SUFFIX_BEING_DELETED;
145extern const char *FTS_SUFFIX_BEING_DELETED_CACHE;
146extern const char *FTS_SUFFIX_CONFIG;
147extern const char *FTS_SUFFIX_DELETED;
148extern const char *FTS_SUFFIX_DELETED_CACHE;
149
150extern const char *FTS_PREFIX_5_7;
151extern const char *FTS_SUFFIX_CONFIG_5_7;
152
153/** Variable specifying the number of word to optimize for each optimize table
154call */
155extern ulong fts_num_word_optimize;
156
157/** Variable specifying whether we do additional FTS diagnostic printout
158in the log */
159extern bool fts_enable_diag_print;
160
161/** FTS rank type, which will be between 0 .. 1 inclusive */
162typedef float fts_rank_t;
163
164/** Structure to manage FTS AUX table name and MDL during its drop */
166 /** AUX table name */
167 std::vector<char *> aux_name;
168};
169
170/** Type of a row during a transaction. FTS_NOTHING means the row can be
171forgotten from the FTS system's POV, FTS_INVALID is an internal value used
172to mark invalid states.
173
174NOTE: Do not change the order or value of these, fts_trx_row_get_new_state
175depends on them being exactly as they are. */
183
184/** The FTS table types. */
186 FTS_INDEX_TABLE, /*!< FTS auxiliary table that is
187 specific to a particular FTS index
188 on a table */
189
190 FTS_COMMON_TABLE, /*!< FTS auxiliary table that is common
191 for all FTS index on a table */
192
193 FTS_OBSOLETED_TABLE /*!< FTS obsoleted tables like DOC_ID,
194 ADDED, STOPWORDS */
196
197struct fts_doc_t;
198struct fts_cache_t;
199struct fts_token_t;
200struct fts_doc_ids_t;
201struct fts_index_cache_t;
202
203/** Initialize the "fts_table" for internal query into FTS auxiliary
204tables */
205#define FTS_INIT_FTS_TABLE(fts_table, m_suffix, m_type, m_table) \
206 do { \
207 (fts_table)->suffix = m_suffix; \
208 (fts_table)->type = m_type; \
209 (fts_table)->table_id = m_table->id; \
210 (fts_table)->parent = m_table->name.m_name; \
211 (fts_table)->table = m_table; \
212 } while (0);
213
214#define FTS_INIT_INDEX_TABLE(fts_table, m_suffix, m_type, m_index) \
215 do { \
216 (fts_table)->suffix = m_suffix; \
217 (fts_table)->type = m_type; \
218 (fts_table)->table_id = m_index->table->id; \
219 (fts_table)->parent = m_index->table->name.m_name; \
220 (fts_table)->table = m_index->table; \
221 (fts_table)->index_id = m_index->id; \
222 } while (0);
223
224/** Information about changes in a single transaction affecting
225the FTS system. */
226struct fts_trx_t {
227 trx_t *trx; /*!< InnoDB transaction */
228
229 ib_vector_t *savepoints; /*!< Active savepoints, must have at
230 least one element, the implied
231 savepoint */
232 ib_vector_t *last_stmt; /*!< last_stmt */
233
234 mem_heap_t *heap; /*!< heap */
235};
236
237/** Information required for transaction savepoint handling. */
239 char *name; /*!< First entry is always NULL, the
240 default instance. Otherwise the name
241 of the savepoint */
242
243 ib_rbt_t *tables; /*!< Modified FTS tables */
244};
245
246/** Information about changed rows in a transaction for a single table. */
248 dict_table_t *table; /*!< table */
249
250 fts_trx_t *fts_trx; /*!< link to parent */
251
252 ib_rbt_t *rows; /*!< rows changed; indexed by doc-id,
253 cells are fts_trx_row_t* */
254
255 fts_doc_ids_t *added_doc_ids; /*!< list of added doc ids (NULL until
256 the first addition) */
257
258 /*!< for adding doc ids */
260};
261
262/** Information about one changed row in a transaction. */
264 doc_id_t doc_id; /*!< Id of the ins/upd/del document */
265
266 fts_row_state state; /*!< state of the row */
267
268 ib_vector_t *fts_indexes; /*!< The indexes that are affected */
269};
270
271/** List of document ids that were added during a transaction. This
272list is passed on to a background 'Add' thread and OPTIMIZE, so it
273needs its own memory heap. */
275 ib_vector_t *doc_ids; /*!< document ids (each element is
276 of type doc_id_t). */
277
278 ib_alloc_t *self_heap; /*!< Allocator used to create an
279 instance of this type and the
280 doc_ids vector */
281};
282
283// FIXME: Get rid of this if possible.
284/** Since MySQL's character set support for Unicode is woefully inadequate
285(it supports basic operations like isalpha etc. only for 8-bit characters),
286we have to implement our own. We use UTF-16 without surrogate processing
287as our in-memory format. This typedef is a single such character. */
288typedef unsigned short ib_uc_t;
289
290/** An UTF-16 ro UTF-8 string. */
292 byte *f_str; /*!< string, not necessary terminated in
293 any way */
294 ulint f_len; /*!< Length of the string in bytes */
295 ulint f_n_char; /*!< Number of characters */
296};
297
298/** Query ranked doc ids. */
300 doc_id_t doc_id; /*!< Document id */
301
302 fts_rank_t rank; /*!< Rank is between 0 .. 1 */
303
304 byte *words; /*!< this contains the words
305 that were queried
306 and found in this document */
307 ulint words_len; /*!< words len */
308};
309
310/** Query result. */
312 ib_rbt_node_t *current; /*!< Current element */
313
314 ib_rbt_t *rankings_by_id; /*!< RB tree of type fts_ranking_t
315 indexed by doc id */
316 ib_rbt_t *rankings_by_rank; /*!< RB tree of type fts_ranking_t
317 indexed by rank */
318};
319
320/** This is used to generate the FTS auxiliary table name, we need the
321table id and the index id to generate the column specific FTS auxiliary
322table name. */
324 const char *parent; /*!< Parent table name, this is
325 required only for the database
326 name */
327
328 fts_table_type_t type; /*!< The auxiliary table type */
329
330 table_id_t table_id; /*!< The table id */
331
332 space_index_t index_id; /*!< The index id */
333
334 const char *suffix; /*!< The suffix of the fts auxiliary
335 table name, can be NULL, not used
336 everywhere (yet) */
337 const dict_table_t *table; /*!< Parent table */
338 CHARSET_INFO *charset; /*!< charset info if it is for FTS
339 index auxiliary table */
340};
341
343 BG_THREAD_STOP = 1, /*!< true if the FTS background thread
344 has finished reading the ADDED table,
345 meaning more items can be added to
346 the table. */
347
348 BG_THREAD_READY = 2, /*!< true if the FTS background thread
349 is ready */
350
351 ADD_THREAD_STARTED = 4, /*!< true if the FTS add thread
352 has started */
353
354 ADDED_TABLE_SYNCED = 8, /*!< true if the ADDED table record is
355 sync-ed after crash recovery */
356};
357
359
360/** The state of the FTS sub system. */
361class fts_t {
362 public:
363 /** fts_t constructor.
364 @param[in] table table with FTS indexes
365 @param[in,out] heap memory heap where 'this' is stored */
366 fts_t(dict_table_t *table, mem_heap_t *heap);
367
368 /** fts_t destructor. */
369 ~fts_t();
370
371 /** Mutex protecting bg_threads* and fts_add_wq. */
373
374 /** Number of background threads accessing this table. */
376
377 /** Status bit regarding fts running state. true if background
378 threads running should stop themselves. */
380
381 /** Work queue for scheduling jobs for the FTS 'Add' thread, or NULL
382 if the thread has not yet been created. Each work item is a
383 fts_trx_doc_ids_t*. */
385
386 /** FTS memory buffer for this table, or NULL if the table has no FTS
387 index. */
389
390 /** FTS doc id hidden column number in the CLUSTERED index. */
392
393 /** Vector of FTS indexes, this is mainly for caching purposes. */
395
396 /** Heap for fts_t allocation. */
398};
399
400struct fts_stopword_t;
401
402/** status bits for fts_stopword_t status field. */
403#define STOPWORD_NOT_INIT 0x1
404#define STOPWORD_OFF 0x2
405#define STOPWORD_FROM_DEFAULT 0x4
406#define STOPWORD_USER_TABLE 0x8
407
408extern const char *fts_default_stopword[];
409
410/** Variable specifying the maximum FTS cache size for each table */
411extern ulong fts_max_cache_size;
412
413/** Variable specifying the total memory allocated for FTS cache */
414extern ulong fts_max_total_cache_size;
415
416/** Variable specifying the FTS result cache limit for each query */
417extern ulong fts_result_cache_limit;
418
419/** Variable specifying the maximum FTS max token size */
420extern ulong fts_max_token_size;
421
422/** Variable specifying the minimum FTS max token size */
423extern ulong fts_min_token_size;
424
425/** Whether the total memory used for FTS cache is exhausted, and we will
426need a sync to free some memory */
427extern bool fts_need_sync;
428
429/** Variable specifying the table that has Fulltext index to display its
430content through information schema table */
431extern char *fts_internal_tbl_name;
432
433#define fts_que_graph_free(graph) \
434 do { \
435 que_graph_free(graph); \
436 } while (0)
437
438/** Create a FTS cache. */
440 dict_table_t *table); /*!< table owns the FTS cache */
441
442/** Create a FTS index cache.
443 @return Index Cache */
445 dict_table_t *table, /*!< in: table with FTS index */
446 dict_index_t *index); /*!< in: FTS index */
447
448/** Remove a FTS index cache
449@param[in] table table with FTS index
450@param[in] index FTS index */
452
453/** Get the next available document id. This function creates a new
454 transaction to generate the document id.
455 @return DB_SUCCESS if OK */
456dberr_t fts_get_next_doc_id(const dict_table_t *table, /*!< in: table */
457 doc_id_t *doc_id); /*!< out: new document id */
458/** Update the next and last Doc ID in the CONFIG table to be the input
459 "doc_id" value (+ 1). We would do so after each FTS index build or
460 table truncate */
462 trx_t *trx, /*!< in/out: transaction */
463 const dict_table_t *table, /*!< in: table */
464 const char *table_name, /*!< in: table name, or NULL */
465 doc_id_t doc_id); /*!< in: DOC ID to set */
466
467/** Create a new document id.
468@param[in] table Row is of this table.
469@param[in,out] row Add doc id value to this row. This is the current row
470that is being inserted.
471@param[in] heap Memory heap on which the doc_id object will be created.
472@return DB_SUCCESS if all went well else error */
474
475/** Create a new fts_doc_ids_t.
476 @return new fts_doc_ids_t. */
478
479/** Free a fts_doc_ids_t. */
480void fts_doc_ids_free(fts_doc_ids_t *doc_ids); /*!< in: doc_ids to free */
481
482/** Notify the FTS system about an operation on an FTS-indexed table.
483@param[in] trx Innodb transaction
484@param[in] table Table
485@param[in] doc_id Doc id
486@param[in] state State of the row
487@param[in] fts_indexes Fts indexes affected (null=all) */
488void fts_trx_add_op(trx_t *trx, dict_table_t *table, doc_id_t doc_id,
489 fts_row_state state, ib_vector_t *fts_indexes);
490
491/** Free an FTS trx. */
492void fts_trx_free(fts_trx_t *fts_trx); /*!< in, own: FTS trx */
493
494/** Check if common tables already exist
495@param[in] table table with fts index
496@return true on success, false on failure */
498
499/** Creates the common auxiliary tables needed for supporting an FTS index
500on the given table. row_mysql_lock_data_dictionary must have been called
501before this.
502The following tables are created.
503CREATE TABLE $FTS_PREFIX_DELETED
504 (doc_id BIGINT UNSIGNED, UNIQUE CLUSTERED INDEX on doc_id)
505CREATE TABLE $FTS_PREFIX_DELETED_CACHE
506 (doc_id BIGINT UNSIGNED, UNIQUE CLUSTERED INDEX on doc_id)
507CREATE TABLE $FTS_PREFIX_BEING_DELETED
508 (doc_id BIGINT UNSIGNED, UNIQUE CLUSTERED INDEX on doc_id)
509CREATE TABLE $FTS_PREFIX_BEING_DELETED_CACHE
510 (doc_id BIGINT UNSIGNED, UNIQUE CLUSTERED INDEX on doc_id)
511CREATE TABLE $FTS_PREFIX_CONFIG
512 (key CHAR(50), value CHAR(200), UNIQUE CLUSTERED INDEX on key)
513@param[in,out] trx transaction
514@param[in] table table with FTS index
515@param[in] name table name normalized
516@param[in] skip_doc_id_index Skip index on doc id
517@return DB_SUCCESS if succeed */
518[[nodiscard]] dberr_t fts_create_common_tables(trx_t *trx,
519 const dict_table_t *table,
520 const char *name,
521 bool skip_doc_id_index);
522
523/** Creates the column specific ancillary tables needed for supporting an
524FTS index on the given table. row_mysql_lock_data_dictionary must have
525been called before this.
526
527All FTS AUX Index tables have the following schema.
528CREATE TABLE $FTS_PREFIX_INDEX_[1-6](
529 word VARCHAR(FTS_MAX_WORD_LEN),
530 first_doc_id INT NOT NULL,
531 last_doc_id UNSIGNED NOT NULL,
532 doc_count UNSIGNED INT NOT NULL,
533 ilist VARBINARY NOT NULL,
534 UNIQUE CLUSTERED INDEX ON (word, first_doc_id))
535@param[in,out] trx transaction
536@param[in] index index instance
537@return DB_SUCCESS or error code */
538[[nodiscard]] dberr_t fts_create_index_tables(trx_t *trx, dict_index_t *index);
539
540/** Create auxiliary index tables for an FTS index.
541@param[in,out] trx transaction
542@param[in] index the index instance
543@param[in] table_name table name
544@param[in] table_id the table id
545@return DB_SUCCESS or error code */
546[[nodiscard]] dberr_t fts_create_index_tables_low(trx_t *trx,
547 dict_index_t *index,
548 const char *table_name,
549 table_id_t table_id);
550
551/** Add the FTS document id hidden column.
552@param[in,out] table Table with FTS index
553@param[in] heap Temporary memory heap, or NULL */
555
556/** Drops the ancillary tables needed for supporting an FTS index on a
557given table. row_mysql_lock_data_dictionary must have been called before
558this.
559@param[in,out] trx transaction
560@param[in] table table has the fts index
561@param[in,out] aux_vec fts aux table name vector
562@return DB_SUCCESS or error code */
564 aux_name_vec_t *aux_vec);
565
566/** Lock all FTS AUX tables (for dropping table)
567@param[in] thd thread locking the AUX table
568@param[in] table table has the fts index
569@return DB_SUCCESS or error code */
571
572/** Drop FTS AUX table DD table objects in vector
573@param[in] aux_vec aux table name vector
574@param[in] file_per_table whether file per table
575@return true on success, false on failure. */
576bool fts_drop_dd_tables(const aux_name_vec_t *aux_vec, bool file_per_table);
577
578/** Free FTS AUX table names in vector
579@param[in] aux_vec aux table name vector
580*/
582
583/** The given transaction is about to be committed; do whatever is necessary
584 from the FTS system's POV.
585 @return DB_SUCCESS or error code */
586[[nodiscard]] dberr_t fts_commit(trx_t *trx); /*!< in: transaction */
587
588/** FTS Query entry point.
589@param[in] trx transaction
590@param[in] index fts index to search
591@param[in] flags FTS search mode
592@param[in] query_str FTS query
593@param[in] query_len FTS query string len in bytes
594@param[in,out] result result doc ids
595@param[in] limit limit value
596@return DB_SUCCESS if successful otherwise error code */
597[[nodiscard]] dberr_t fts_query(trx_t *trx, dict_index_t *index, uint flags,
598 const byte *query_str, ulint query_len,
599 fts_result_t **result, ulonglong limit);
600
601/** Retrieve the FTS Relevance Ranking result for doc with doc_id
602 @return the relevance ranking value. */
604 fts_result_t *result, /*!< in: FTS result structure */
605 doc_id_t doc_id); /*!< in: the interested document
606 doc_id */
607
608/** FTS Query sort result, returned by fts_query() on fts_ranking_t::rank. */
610 instance to sort.*/
611
612/** FTS Query free result, returned by fts_query(). */
613void fts_query_free_result(fts_result_t *result); /*!< in: result instance
614 to free.*/
615
616/** Extract the doc id from the FTS hidden column. */
617doc_id_t fts_get_doc_id_from_row(dict_table_t *table, /*!< in: table */
618 dtuple_t *row); /*!< in: row whose FTS doc id
619 we want to extract.*/
620
621/** Extract the doc id from the record that belongs to index.
622@param[in] table table
623@param[in] rec record contains FTS_DOC_ID
624@param[in] index index of rec
625@param[in] heap heap memory
626@return doc id that was extracted from rec */
628 const dict_index_t *index, mem_heap_t *heap);
629
630/** Add new fts doc id to the update vector.
631@param[in] table the table that contains the FTS index.
632@param[in,out] ufield the fts doc id field in the update vector.
633 No new memory is allocated for this in this
634 function.
635@param[in,out] next_doc_id the fts doc id that has been added to the
636 update vector. If 0, a new fts doc id is
637 automatically generated. The memory provided
638 for this argument will be used by the update
639 vector. Ensure that the life time of this
640 memory matches that of the update vector.
641@return the fts doc id used in the update vector */
643 doc_id_t *next_doc_id);
644
645/** FTS initialize. */
646void fts_startup(void);
647
648#if 0 // TODO: Enable this in WL#6608
649/******************************************************************//**
650Signal FTS threads to initiate shutdown. */
651void
652fts_start_shutdown(
653 dict_table_t* table, /*!< in: table with FTS
654 indexes */
655 fts_t* fts); /*!< in: fts instance to
656 shutdown */
657
658/******************************************************************//**
659Wait for FTS threads to shutdown. */
660void
661fts_shutdown(
662 dict_table_t* table, /*!< in: table with FTS
663 indexes */
664 fts_t* fts); /*!< in: fts instance to
665 shutdown */
666#endif
667
668/** Create an instance of fts_t.
669 @return instance of fts_t */
670fts_t *fts_create(dict_table_t *table); /*!< out: table with FTS
671 indexes */
672
673/** Free the FTS resources. */
674void fts_free(dict_table_t *table); /*!< in/out: table with
675 FTS indexes */
676
677/** Run OPTIMIZE on the given table.
678 @return DB_SUCCESS if all OK */
679dberr_t fts_optimize_table(dict_table_t *table); /*!< in: table to optimiza */
680
681/** Startup the optimize thread and create the work queue. */
682void fts_optimize_init(void);
683
684/** Since we do a horizontal split on the index table, we need to drop
685all the split tables.
686@param[in] trx transaction
687@param[in] index fts index
688@param[out] aux_vec dropped table names vector
689@return DB_SUCCESS or error code */
691 aux_name_vec_t *aux_vec);
692
693/** Empty all common talbes.
694@param[in,out] trx transaction
695@param[in] table dict table
696@return DB_SUCCESS or error code. */
698
699/** Remove the table from the OPTIMIZER's list. We do wait for
700 acknowledgement from the consumer of the message. */
701void fts_optimize_remove_table(dict_table_t *table); /*!< in: table to remove */
702
703/** Shutdown fts optimize thread. */
705
706/** Send sync fts cache for the table.
707@param[in] table table to sync */
709
710/** Take a FTS savepoint.
711@param[in] fts_trx Fts transaction
712@param[in] name Savepoint name */
713void fts_savepoint_take(fts_trx_t *fts_trx, const char *name);
714
715/** Refresh last statement savepoint. */
716void fts_savepoint_laststmt_refresh(trx_t *trx); /*!< in: transaction */
717
718/** Release the savepoint data identified by name. */
719void fts_savepoint_release(trx_t *trx, /*!< in: transaction */
720 const char *name); /*!< in: savepoint name */
721
722/** Clear cache.
723@param[in,out] cache fts cache */
724void fts_cache_clear(fts_cache_t *cache);
725
726/** Initialize things in cache. */
727void fts_cache_init(fts_cache_t *cache); /*!< in: cache */
728
729/** Rollback to and including savepoint identified by name. */
730void fts_savepoint_rollback(trx_t *trx, /*!< in: transaction */
731 const char *name); /*!< in: savepoint name */
732
733/** Rollback to and including savepoint identified by name. */
734void fts_savepoint_rollback_last_stmt(trx_t *trx); /*!< in: transaction */
735
736/* Get parent table name if it's a fts aux table
737@param[in] aux_table_name aux table name
738@param[in] aux_table_len aux table length
739@return parent table name, or NULL */
740char *fts_get_parent_table_name(const char *aux_table_name,
741 ulint aux_table_len);
742
743/** Run SYNC on the table, i.e., write out data from the cache to the
744FTS auxiliary INDEX table and clear the cache at the end.
745@param[in,out] table fts table
746@param[in] unlock_cache whether unlock cache when write node
747@param[in] wait whether wait for existing sync to finish
748@param[in] has_dict whether has dict operation lock
749@return DB_SUCCESS on success, error code on failure. */
750dberr_t fts_sync_table(dict_table_t *table, bool unlock_cache, bool wait,
751 bool has_dict);
752
753/** Create an FTS index cache. */
754CHARSET_INFO *fts_index_get_charset(dict_index_t *index); /*!< in: FTS index */
755
756/** Get the initial Doc ID by consulting the CONFIG table
757 @return initial Doc ID */
758doc_id_t fts_init_doc_id(const dict_table_t *table); /*!< in: table */
759
760/** Compare two character string according to their charset.
761@param[in] cs Character set
762@param[in] p1 Key
763@param[in] p2 Node */
764extern int innobase_fts_text_cmp(const void *cs, const void *p1,
765 const void *p2);
766
767/** Makes all characters in a string lower case.
768@param[in] cs Character set
769@param[in] src String to put in lower case
770@param[in] src_len Input string length
771@param[in] dst Buffer for result string
772@param[in] dst_len Buffer size */
773extern size_t innobase_fts_casedn_str(CHARSET_INFO *cs, char *src,
774 size_t src_len, char *dst,
775 size_t dst_len);
776
777/** Compare two character string according to their charset.
778@param[in] cs Character set
779@param[in] p1 Key
780@param[in] p2 Node */
781extern int innobase_fts_text_cmp_prefix(const void *cs, const void *p1,
782 const void *p2);
783
784/** Get the next token from the given string and store it in *token. */
786 CHARSET_INFO *charset, /*!< in: Character set */
787 const byte *start, /*!< in: start of text */
788 const byte *end, /*!< in: one character past
789 end of text */
790 fts_string_t *token); /*!< out: token's text */
791
792/** Drop dd table & tablespace for fts aux table
793@param[in] name table name
794@param[in] file_per_table flag whether use file per table
795@return true on success, false on failure. */
796bool innobase_fts_drop_dd_table(const char *name, bool file_per_table);
797
798/** Get token char size by charset
799 @return the number of token char size */
800ulint fts_get_token_size(const CHARSET_INFO *cs, /*!< in: Character set */
801 const char *token, /*!< in: token */
802 ulint len); /*!< in: token length */
803
804/** FULLTEXT tokenizer internal in MYSQL_FTPARSER_SIMPLE_MODE
805 @return 0 if tokenize successfully */
807 MYSQL_FTPARSER_PARAM *param, /*!< in: parser parameter */
808 char *doc, /*!< in: document to tokenize */
809 int len); /*!< in: document length */
810
811/** Fetch COUNT(*) from specified table.
812 @return the number of rows in the table */
813ulint fts_get_rows_count(fts_table_t *fts_table); /*!< in: fts table to read */
814
815/** Get maximum Doc ID in a table if index "FTS_DOC_ID_INDEX" exists
816 @return max Doc ID or 0 if index "FTS_DOC_ID_INDEX" does not exist */
817doc_id_t fts_get_max_doc_id(dict_table_t *table); /*!< in: user table */
818
819/** Check whether user supplied stopword table exists and is of
820 the right format.
821 @return the stopword column charset if qualifies */
823 const char *stopword_table_name); /*!< in: Stopword table
824 name */
825/** This function loads specified stopword into FTS cache
826 @return true if success */
828 const dict_table_t *table, /*!< in: Table with FTS */
829 trx_t *trx, /*!< in: Transaction */
830 const char *global_stopword_table, /*!< in: Global stopword table
831 name */
832 const char *session_stopword_table, /*!< in: Session stopword table
833 name */
834 bool stopword_is_on, /*!< in: Whether stopword
835 option is turned on/off */
836 bool reload); /*!< in: Whether it is during
837 reload of FTS table */
838
839/** Read the rows from the FTS index
840 @return DB_SUCCESS if OK */
841dberr_t fts_table_fetch_doc_ids(trx_t *trx, /*!< in: transaction */
842 fts_table_t *fts_table, /*!< in: aux table */
843 fts_doc_ids_t *doc_ids); /*!< in: For collecting
844 doc ids */
845/** This function brings FTS index in sync when FTS index is first
846 used. There are documents that have not yet sync-ed to auxiliary
847 tables from last server abnormally shutdown, we will need to bring
848 such document into FTS cache before any further operations
849 @return true if all OK */
850bool fts_init_index(dict_table_t *table, /*!< in: Table with FTS */
851 bool has_cache_lock); /*!< in: Whether we already
852 have cache lock */
853/** Add a newly create index in FTS cache */
854void fts_add_index(dict_index_t *index, /*!< FTS index to be added */
855 dict_table_t *table); /*!< table */
856
857/** Drop auxiliary tables related to an FTS index
858@param[in] table Table where indexes are dropped
859@param[in] index Index to be dropped
860@param[in] trx Transaction for the drop
861@param[in,out] aux_vec Aux table name vector
862@return DB_SUCCESS or error number */
864 aux_name_vec_t *aux_vec);
865
866/** Rename auxiliary tables for all fts index for a table
867 @return DB_SUCCESS or error code */
868dberr_t fts_rename_aux_tables(dict_table_t *table, /*!< in: user Table */
869 const char *new_name, /*!< in: new table name */
870 trx_t *trx, /*!< in: transaction */
871 bool replay); /*!< Whether in replay
872 stage */
873
874/** Check indexes in the fts->indexes is also present in index cache and
875 table->indexes list
876 @return true if all indexes match */
878 dict_table_t *table); /*!< in: Table where indexes are dropped */
879
880/** Fetch the document from tuple, tokenize the text data and
881insert the text data into fts auxiliary table and
882its cache. Moreover this tuple fields doesn't contain any information
883about externally stored field. This tuple contains data directly
884converted from mysql.
885@param[in] ftt FTS transaction table
886@param[in] doc_id doc id
887@param[in] tuple tuple from where data can be retrieved
888 and tuple should be arranged in table
889 schema order. */
891 const dtuple_t *tuple);
892
893/** Create an FTS trx.
894@param[in,out] trx InnoDB Transaction
895@return FTS transaction. */
897
898/** For storing table info when checking for orphaned tables. */
900 /** Table id */
902
903 /** Parent table id */
905
906 /** Table FT index id */
908
909 /** Name of the table */
910 char *name;
911
912 /** FTS table type */
914};
915
916/** Check if a table is an FTS auxiliary table name.
917@param[out] table FTS table info
918@param[in] name Table name
919@param[in] len Length of table name
920@return true if the name matches an auxiliary table name pattern */
921bool fts_is_aux_table_name(fts_aux_table_t *table, const char *name, ulint len);
922
923/** Freeze all auiliary tables to be not evictable if exist, with dict_mutex
924held
925@param[in] table InnoDB table object */
926void fts_freeze_aux_tables(const dict_table_t *table);
927
928/** Allow all the auxiliary tables of specified base table to be evictable
929if they exist, if not exist just ignore
930@param[in] table InnoDB table object
931@param[in] dict_locked True if we have dict_sys mutex */
932void fts_detach_aux_tables(const dict_table_t *table, bool dict_locked);
933
934/** Update DD system table for auxiliary common tables for an FTS index.
935@param[in] table dict table instance
936@return true on success, false on failure */
938
939/** Check if a table has FTS index needs to have its auxiliary index
940tables' metadata updated in DD
941@param[in,out] table table to check
942@return DB_SUCCESS or error code */
944
945/** Upgrade FTS AUX Tables. The FTS common and aux tables are
946renamed because they have table_id in their name. We move table_ids
947by DICT_MAX_DD_TABLES offset. Aux tables are registered into DD
948after rename.
949@param[in] table InnoDB table object
950@return DB_SUCCESS or error code */
952
953/** Rename FTS AUX tablespace name from 8.0 format to 5.7 format.
954This will be done on upgrade failure
955@param[in] table parent table
956@param[in] rollback rollback the rename from 8.0 to 5.7
957 if true, rename to 5.7 format
958 if false, mark the table as evictable
959@return DB_SUCCESS on success, DB_ERROR on error */
961
962#endif
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:922
The state of the FTS sub system.
Definition: fts0fts.h:361
fts_cache_t * cache
FTS memory buffer for this table, or NULL if the table has no FTS index.
Definition: fts0fts.h:388
ulint bg_threads
Number of background threads accessing this table.
Definition: fts0fts.h:375
mem_heap_t * fts_heap
Heap for fts_t allocation.
Definition: fts0fts.h:397
~fts_t()
fts_t destructor.
Definition: fts0fts.cc:5411
ib_mutex_t bg_threads_mutex
Mutex protecting bg_threads* and fts_add_wq.
Definition: fts0fts.h:372
ulint doc_col
FTS doc id hidden column number in the CLUSTERED index.
Definition: fts0fts.h:391
ib_wqueue_t * add_wq
Work queue for scheduling jobs for the FTS 'Add' thread, or NULL if the thread has not yet been creat...
Definition: fts0fts.h:384
ulint fts_status
Status bit regarding fts running state.
Definition: fts0fts.h:379
fts_t(dict_table_t *table, mem_heap_t *heap)
fts_t constructor.
Definition: fts0fts.cc:5392
ib_vector_t * indexes
Vector of FTS indexes, this is mainly for caching purposes.
Definition: fts0fts.h:394
Data types.
Some type definitions.
dberr_t
Definition: db0err.h:38
Data dictionary global types.
ib_id_t space_index_t
Index identifier (unique within a tablespace).
Definition: dict0types.h:219
ib_id_t table_id_t
Table or partition identifier (unique within an InnoDB instance).
Definition: dict0types.h:217
Some definitions for full-text indices.
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.
Definition: ha_innodb.cc:7793
const char * FTS_SUFFIX_CONFIG_5_7
Definition: fts0fts.cc:147
fts_trx_t * fts_trx_create(trx_t *trx)
Create an FTS trx.
Definition: fts0fts.cc:2476
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.
Definition: fts0fts.cc:2330
int fts_tokenize_document_internal(MYSQL_FTPARSER_PARAM *param, char *doc, int len)
FULLTEXT tokenizer internal in MYSQL_FTPARSER_SIMPLE_MODE.
Definition: fts0fts.cc:4686
dberr_t fts_create_doc_id(dict_table_t *table, dtuple_t *row, mem_heap_t *heap)
Create a new document id.
Definition: fts0fts.cc:3130
uint64_t doc_id_t
Document id type.
Definition: fts0fts.h:76
float fts_retrieve_ranking(fts_result_t *result, doc_id_t doc_id)
Retrieve the FTS Relevance Ranking result for doc with doc_id.
Definition: fts0que.cc:3316
void fts_query_sort_result_on_rank(fts_result_t *result)
FTS Query sort result, returned by fts_query() on fts_ranking_t::rank.
Definition: fts0que.cc:3849
void fts_startup(void)
FTS initialize.
void fts_optimize_request_sync_table(dict_table_t *table)
Send sync fts cache for the table.
Definition: fts0opt.cc:2497
dberr_t fts_upgrade_aux_tables(dict_table_t *table)
Upgrade FTS AUX Tables.
Definition: fts0fts.cc:6343
void fts_optimize_shutdown()
Shutdown fts optimize thread.
Definition: fts0opt.cc:2950
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.
Definition: fts0fts.cc:2245
fts_doc_ids_t * fts_doc_ids_create(void)
Create a new fts_doc_ids_t.
Definition: fts0fts.cc:2976
void fts_add_doc_id_column(dict_table_t *table, mem_heap_t *heap)
Add the FTS document id hidden column.
Definition: fts0fts.cc:5328
const char * FTS_SUFFIX_BEING_DELETED_CACHE
Definition: fts0fts.cc:137
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.
Definition: fts0fts.cc:5350
ulong fts_result_cache_limit
Variable specifying the FTS result cache limit for each query.
Definition: fts0fts.cc:84
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 tab...
Definition: fts0fts.cc:3492
const char * fts_default_stopword[]
InnoDB default stopword list: There are different versions of stopwords, the stop words listed below ...
Definition: fts0fts.cc:118
dberr_t fts_get_next_doc_id(const dict_table_t *table, doc_id_t *doc_id)
Get the next available document id.
Definition: fts0fts.cc:2763
fts_index_cache_t * fts_cache_index_cache_create(dict_table_t *table, dict_index_t *index)
Create a FTS index cache.
Definition: fts0fts.cc:817
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.
Definition: fts0que.cc:3618
void fts_savepoint_rollback(trx_t *trx, const char *name)
Rollback to and including savepoint identified by name.
Definition: fts0fts.cc:5694
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.
Definition: fts0fts.cc:1235
bool fts_check_common_tables_exist(const dict_table_t *table)
Check if common tables already exist.
Definition: fts0fts.cc:1864
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.
Definition: fts0fts.cc:3746
void fts_add_index(dict_index_t *index, dict_table_t *table)
Add a newly create index in FTS cache.
Definition: fts0fts.cc:578
char * fts_internal_tbl_name
Variable specifying the table that has Fulltext index to display its content through information sche...
Definition: fts0fts.cc:110
const char * FTS_SUFFIX_CONFIG
Definition: fts0fts.cc:138
void fts_savepoint_take(fts_trx_t *fts_trx, const char *name)
Take a FTS savepoint.
Definition: fts0fts.cc:5510
enum fts_status fts_status_t
Definition: fts0fts.h:358
void fts_cache_index_cache_remove(dict_table_t *table, dict_index_t *index)
Remove a FTS index cache.
Definition: fts0fts.cc:861
void fts_optimize_init(void)
Startup the optimize thread and create the work queue.
Definition: fts0opt.cc:2933
void fts_trx_free(fts_trx_t *fts_trx)
Free an FTS trx.
Definition: fts0fts.cc:5115
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).
Definition: fts0fts.cc:2746
dberr_t fts_optimize_table(dict_table_t *table)
Run OPTIMIZE on the given table.
Definition: fts0opt.cc:2317
ulong fts_max_cache_size
Variable specifying the maximum FTS cache size for each table.
Definition: fts0fts.cc:73
void fts_free_aux_names(aux_name_vec_t *aux_vec)
Free FTS AUX table names in vector.
Definition: fts0fts.cc:1257
void fts_savepoint_release(trx_t *trx, const char *name)
Release the savepoint data identified by name.
Definition: fts0fts.cc:5556
doc_id_t fts_init_doc_id(const dict_table_t *table)
Get the initial Doc ID by consulting the CONFIG table.
Definition: fts0fts.cc:4888
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...
Definition: fts0fts.cc:4453
fts_t * fts_create(dict_table_t *table)
Create an instance of fts_t.
Definition: fts0fts.cc:5428
ulong fts_max_token_size
Variable specifying the maximum FTS max token size.
Definition: fts0fts.cc:87
void fts_doc_ids_free(fts_doc_ids_t *doc_ids)
Free a fts_doc_ids_t.
Definition: fts0fts.cc:2992
fts_table_type_t
The FTS table types.
Definition: fts0fts.h:185
@ FTS_INDEX_TABLE
FTS auxiliary table that is specific to a particular FTS index on a table.
Definition: fts0fts.h:186
@ FTS_OBSOLETED_TABLE
FTS obsoleted tables like DOC_ID, ADDED, STOPWORDS.
Definition: fts0fts.h:193
@ FTS_COMMON_TABLE
FTS auxiliary table that is common for all FTS index on a table.
Definition: fts0fts.h:190
bool innobase_fts_drop_dd_table(const char *name, bool file_per_table)
Drop dd table & tablespace for fts aux table.
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.
Definition: fts0fts.cc:5943
int innobase_fts_text_cmp_prefix(const void *cs, const void *p1, const void *p2)
Compare two character string according to their charset.
Definition: ha_innodb.cc:7772
void fts_cache_init(fts_cache_t *cache)
Initialize things in cache.
Definition: fts0fts.cc:496
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.
Definition: fts0fts.cc:2267
int innobase_fts_text_cmp(const void *cs, const void *p1, const void *p2)
Compare two character string according to their charset.
Definition: ha_innodb.cc:7699
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.
Definition: fts0fts.cc:5154
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.
Definition: fts0fts.cc:671
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.
Definition: fts0fts.cc:1642
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.
Definition: fts0fts.cc:5179
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.
Definition: fts0fts.cc:6193
dberr_t fts_drop_index(dict_table_t *table, dict_index_t *index, trx_t *trx, aux_name_vec_t *aux_vec)
Drop auxiliary tables related to an FTS index.
Definition: fts0fts.cc:706
bool fts_create_common_dd_tables(const dict_table_t *table)
Update DD system table for auxiliary common tables for an FTS index.
Definition: fts0fts.cc:2171
ulint fts_get_rows_count(fts_table_t *fts_table)
Fetch COUNT(*) from specified table.
Definition: fts0fts.cc:4954
bool fts_need_sync
Whether the total memory used for FTS cache is exhausted, and we will need a sync to free some memory...
Definition: fts0fts.cc:77
const char * FTS_SUFFIX_BEING_DELETED
Definition: fts0fts.cc:136
bool fts_enable_diag_print
Variable specifying whether we do additional FTS diagnostic printout in the log.
Definition: fts0opt.cc:243
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.
Definition: fts0fts.cc:1481
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.
Definition: fts0fts.cc:1384
constexpr size_t FTS_NUM_AUX_INDEX
The number of FTS index partitions for a fulltext index.
Definition: fts0fts.h:105
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,...
Definition: fts0fts.cc:2106
const char * FTS_PREFIX
FTS auxiliary table prefix that are common to all FT indexes.
Definition: fts0fts.cc:126
void fts_optimize_remove_table(dict_table_t *table)
Remove the table from the OPTIMIZER's list.
Definition: fts0opt.cc:2467
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.
Definition: fts0fts.cc:1912
ulong fts_min_token_size
Variable specifying the minimum FTS max token size.
Definition: fts0fts.cc:90
CHARSET_INFO * fts_index_get_charset(dict_index_t *index)
Create an FTS index cache.
Definition: fts0fts.cc:782
fts_cache_t * fts_cache_create(dict_table_t *table)
Create a FTS cache.
Definition: fts0fts.cc:525
fts_status
Definition: fts0fts.h:342
@ BG_THREAD_STOP
true if the FTS background thread has finished reading the ADDED table, meaning more items can be add...
Definition: fts0fts.h:343
@ BG_THREAD_READY
true if the FTS background thread is ready
Definition: fts0fts.h:348
@ ADDED_TABLE_SYNCED
true if the ADDED table record is sync-ed after crash recovery
Definition: fts0fts.h:354
@ ADD_THREAD_STARTED
true if the FTS add thread has started
Definition: fts0fts.h:351
CHARSET_INFO * fts_valid_stopword_table(const char *stopword_table_name)
Check whether user supplied stopword table exists and is of the right format.
Definition: fts0fts.cc:5882
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.
Definition: fts0fts.cc:6447
dberr_t fts_lock_all_aux_tables(THD *thd, dict_table_t *table)
Lock all FTS AUX tables (for dropping table)
Definition: fts0fts.cc:1741
const char * FTS_PREFIX_5_7
FTS auxiliary table prefix that are common to all FT indexes.
Definition: fts0fts.cc:129
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.
Definition: fts0fts.cc:3222
void fts_cache_clear(fts_cache_t *cache)
Clear cache.
Definition: fts0fts.cc:912
void fts_freeze_aux_tables(const dict_table_t *table)
Freeze all auiliary tables to be not evictable if exist, with dict_mutex held.
Definition: fts0fts.cc:2052
dberr_t fts_empty_common_tables(trx_t *trx, dict_table_t *table)
Empty all common talbes.
Definition: fts0fts.cc:1578
char * fts_get_parent_table_name(const char *aux_table_name, ulint aux_table_len)
ulong fts_max_total_cache_size
Variable specifying the total memory allocated for FTS cache.
Definition: fts0fts.cc:80
void fts_savepoint_rollback_last_stmt(trx_t *trx)
Rollback to and including savepoint identified by name.
Definition: fts0fts.cc:5654
void fts_savepoint_laststmt_refresh(trx_t *trx)
Refresh last statement savepoint.
Definition: fts0fts.cc:5593
void fts_free(dict_table_t *table)
Free the FTS resources.
Definition: fts0fts.cc:5443
ulong fts_num_word_optimize
Variable specifying the number of word to optimize for each optimize table call.
Definition: fts0opt.cc:240
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.
Definition: ha_innodb.cc:7814
float fts_rank_t
FTS rank type, which will be between 0 .
Definition: fts0fts.h:162
const char * FTS_SUFFIX_DELETED
Definition: fts0fts.cc:139
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.
Definition: fts0opt.cc:901
void fts_query_free_result(fts_result_t *result)
FTS Query free result, returned by fts_query().
Definition: fts0que.cc:3830
ulint fts_get_token_size(const CHARSET_INFO *cs, const char *token, ulint len)
Get token char size by charset.
Definition: fts0fts.cc:4657
constexpr size_t FTS_NUM_AUX_COMMON
The number of FTS AUX common table for a fulltext index.
Definition: fts0fts.h:108
fts_row_state
Type of a row during a transaction.
Definition: fts0fts.h:176
@ FTS_DELETE
Definition: fts0fts.h:179
@ FTS_INVALID
Definition: fts0fts.h:181
@ FTS_MODIFY
Definition: fts0fts.h:178
@ FTS_NOTHING
Definition: fts0fts.h:180
@ FTS_INSERT
Definition: fts0fts.h:177
unsigned short ib_uc_t
Since MySQL's character set support for Unicode is woefully inadequate (it supports basic operations ...
Definition: fts0fts.h:288
const char * FTS_SUFFIX_DELETED_CACHE
Definition: fts0fts.cc:140
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.
Definition: fts0fts.cc:2636
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.
Definition: fts0fts.cc:5752
Prototypes for global functions in ha_innodb.cc that are called by InnoDB C code.
The simple hash table utility.
static int flags[50]
Definition: hp_test1.cc:39
static void start(mysql_harness::PluginFuncEnv *env)
Definition: http_auth_backend_plugin.cc:176
The memory management.
unsigned long long int ulonglong
Definition: my_inttypes.h:55
const std::string charset("charset")
Definition: commit_order_queue.h:33
stdx::expected< size_t, std::error_code > wait(int epfd, epoll_event *fd_events, size_t num_fd_events, std::chrono::milliseconds timeout)
Definition: linux_epoll.h:82
const char * table_name
Definition: rules_table_service.cc:55
Cursor end()
A past-the-end Cursor.
Definition: rules_table_service.cc:191
Query graph global types.
Record manager global types.
byte rec_t
Definition: rem0types.h:40
static bool reload(MYSQL_THD thd)
Reloads the rules into the in-memory table.
Definition: rewriter_plugin.cc:332
Row operation global types.
static bool rollback(THD *thd)
Abort the current statement and transaction.
Definition: sql_cmd_srs.cc:139
case opt name
Definition: sslopt-case.h:32
Definition: m_ctype.h:382
Definition: plugin_ftparser.h:190
Structure to manage FTS AUX table name and MDL during its drop.
Definition: fts0fts.h:165
std::vector< char * > aux_name
AUX table name.
Definition: fts0fts.h:167
Data structure for an index.
Definition: dict0mem.h:1021
Data structure for a database table.
Definition: dict0mem.h:1884
Structure for an SQL data tuple of fields (logical record)
Definition: data0data.h:681
For storing table info when checking for orphaned tables.
Definition: fts0fts.h:899
fts_table_type_t type
FTS table type.
Definition: fts0fts.h:913
table_id_t index_id
Table FT index id.
Definition: fts0fts.h:907
char * name
Name of the table.
Definition: fts0fts.h:910
table_id_t id
Table id.
Definition: fts0fts.h:901
table_id_t parent_id
Parent table id.
Definition: fts0fts.h:904
The cache for the FTS system.
Definition: fts0types.h:143
List of document ids that were added during a transaction.
Definition: fts0fts.h:274
ib_vector_t * doc_ids
document ids (each element is of type doc_id_t).
Definition: fts0fts.h:275
ib_alloc_t * self_heap
Allocator used to create an instance of this type and the doc_ids vector.
Definition: fts0fts.h:278
This type represents a single document.
Definition: fts0types.h:267
Since we can have multiple FTS indexes on a table, we keep a per index cache of words etc.
Definition: fts0types.h:70
Query ranked doc ids.
Definition: fts0fts.h:299
ulint words_len
words len
Definition: fts0fts.h:307
fts_rank_t rank
Rank is between 0 .
Definition: fts0fts.h:302
byte * words
this contains the words that were queried and found in this document
Definition: fts0fts.h:304
doc_id_t doc_id
Document id.
Definition: fts0fts.h:300
Query result.
Definition: fts0fts.h:311
ib_rbt_t * rankings_by_id
RB tree of type fts_ranking_t indexed by doc id.
Definition: fts0fts.h:314
ib_rbt_t * rankings_by_rank
RB tree of type fts_ranking_t indexed by rank.
Definition: fts0fts.h:316
ib_rbt_node_t * current
Current element.
Definition: fts0fts.h:312
Information required for transaction savepoint handling.
Definition: fts0fts.h:238
ib_rbt_t * tables
Modified FTS tables.
Definition: fts0fts.h:243
char * name
First entry is always NULL, the default instance.
Definition: fts0fts.h:239
Stop word control infotmation.
Definition: fts0types.h:104
ib_alloc_t * heap
The memory allocator to use.
Definition: fts0types.h:106
An UTF-16 ro UTF-8 string.
Definition: fts0fts.h:291
ulint f_n_char
Number of characters.
Definition: fts0fts.h:295
ulint f_len
Length of the string in bytes.
Definition: fts0fts.h:294
byte * f_str
string, not necessary terminated in any way
Definition: fts0fts.h:292
This is used to generate the FTS auxiliary table name, we need the table id and the index id to gener...
Definition: fts0fts.h:323
space_index_t index_id
The index id.
Definition: fts0fts.h:332
CHARSET_INFO * charset
charset info if it is for FTS index auxiliary table
Definition: fts0fts.h:338
fts_table_type_t type
The auxiliary table type.
Definition: fts0fts.h:328
const dict_table_t * table
Parent table.
Definition: fts0fts.h:337
table_id_t table_id
The table id.
Definition: fts0fts.h:330
const char * suffix
The suffix of the fts auxiliary table name, can be NULL, not used everywhere (yet)
Definition: fts0fts.h:334
const char * parent
Parent table name, this is required only for the database name.
Definition: fts0fts.h:324
A token and its positions within a document.
Definition: fts0types.h:293
Information about one changed row in a transaction.
Definition: fts0fts.h:263
doc_id_t doc_id
Id of the ins/upd/del document.
Definition: fts0fts.h:264
fts_row_state state
state of the row
Definition: fts0fts.h:266
ib_vector_t * fts_indexes
The indexes that are affected.
Definition: fts0fts.h:268
Information about changes in a single transaction affecting the FTS system.
Definition: fts0fts.h:226
ib_vector_t * last_stmt
last_stmt
Definition: fts0fts.h:232
mem_heap_t * heap
heap
Definition: fts0fts.h:234
trx_t * trx
InnoDB transaction.
Definition: fts0fts.h:227
ib_vector_t * savepoints
Active savepoints, must have at least one element, the implied savepoint.
Definition: fts0fts.h:229
Information about changed rows in a transaction for a single table.
Definition: fts0fts.h:247
ib_rbt_t * rows
rows changed; indexed by doc-id, cells are fts_trx_row_t*
Definition: fts0fts.h:252
fts_trx_t * fts_trx
link to parent
Definition: fts0fts.h:250
dict_table_t * table
table
Definition: fts0fts.h:248
que_t * docs_added_graph
Definition: fts0fts.h:259
fts_doc_ids_t * added_doc_ids
list of added doc ids (NULL until the first addition)
Definition: fts0fts.h:255
Definition: ut0vec.h:203
Red black tree node.
Definition: ut0rbt.h:60
Red black tree instance.
Definition: ut0rbt.h:71
Definition: ut0vec.h:212
Definition: ut0wqueue.cc:42
The info structure stored at the beginning of a heap block.
Definition: mem0mem.h:299
Definition: que0que.h:300
Definition: result.h:29
Definition: trx0trx.h:680
Definition: row0upd.h:466
Transaction system global type definitions.
unsigned int uint
Definition: uca-dump.cc:29
unsigned long int ulint
Definition: univ.i:407
Various utilities.
A vector of pointers to data items.
A work queue.