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