| 1 | /***************************************************************************** |
| 2 | |
| 3 | Copyright (c) 2011, 2018, Oracle and/or its affiliates. All Rights Reserved. |
| 4 | Copyright (c) 2016, 2022, MariaDB Corporation. |
| 5 | |
| 6 | This program is free software; you can redistribute it and/or modify it under |
| 7 | the terms of the GNU General Public License as published by the Free Software |
| 8 | Foundation; version 2 of the License. |
| 9 | |
| 10 | This program is distributed in the hope that it will be useful, but WITHOUT |
| 11 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 12 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU General Public License along with |
| 15 | this program; if not, write to the Free Software Foundation, Inc., |
| 16 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA |
| 17 | |
| 18 | *****************************************************************************/ |
| 19 | |
| 20 | /******************************************************************//** |
| 21 | @file include/fts0fts.h |
| 22 | Full text search header file |
| 23 | |
| 24 | Created 2011/09/02 Sunny Bains |
| 25 | ***********************************************************************/ |
| 26 | |
| 27 | #pragma once |
| 28 | |
| 29 | #include "data0type.h"cxx . . $ `<file>/storage/innobase/include/data0type.h`/ |
| 30 | #include "data0types.h"cxx . . $ `<file>/storage/innobase/include/data0types.h`/ |
| 31 | #include "mem0mem.h"cxx . . $ `<file>/storage/innobase/include/mem0mem.h`/ |
| 32 | #include "rem0types.h"cxx . . $ `<file>/storage/innobase/include/rem0types.h`/ |
| 33 | #include "row0types.h"cxx . . $ `<file>/storage/innobase/include/row0types.h`/ |
| 34 | #include "trx0types.h"cxx . . $ `<file>/storage/innobase/include/trx0types.h`/ |
| 35 | #include "ut0vec.h"cxx . . $ `<file>/storage/innobase/include/ut0vec.h`/ |
| 36 | #include "ut0rbt.h"cxx . . $ `<file>/storage/innobase/include/ut0rbt.h`/ |
| 37 | #include "ut0wqueue.h"cxx . . $ `<file>/storage/innobase/include/ut0wqueue.h`/ |
| 38 | #include "que0types.h"cxx . . $ `<file>/storage/innobase/include/que0types.h`/ |
| 39 | #include "ft_global.h"cxx . . $ `<file>/include/ft_global.h`/ |
| 40 | #include "mysql/plugin_ftparser.h"cxx . . $ `<file>/include/mysql/plugin_ftparser.h`/ |
| 41 | #include "lex_string.h"cxx . . $ `<file>/sql/lex_string.h`/ |
| 42 | |
| 43 | /** "NULL" value of a document id. */ |
| 44 | #define FTS_NULL_DOC_IDcxx . . $ `storage/innobase/include/fts0fts.h:44:9`! 0 |
| 45 | |
| 46 | /** FTS hidden column that is used to map to and from the row */ |
| 47 | static constexpr Lex_cstringcxx . . $ Lex_cstring# FTS_DOC_IDcxx . . $ FTS_DOC_ID.= "FTS_DOC_ID"cxx . . $ Lex_cstring#Lex_cstring(37cd5eac6a9dc7c8)._LEX_CSTRINGcxx . . $ `operator""_LEX_CSTRING`(644ae2aac2bb416c).; |
| 48 | |
| 49 | /** The name of the index created by FTS */ |
| 50 | static constexpr Lex_cstringcxx . . $ Lex_cstring# FTS_DOC_ID_INDEXcxx . . $ FTS_DOC_ID_INDEX.= "FTS_DOC_ID_INDEX"cxx . . $ Lex_cstring#Lex_cstring(37cd5eac6a9dc7c8)._LEX_CSTRINGcxx . . $ `operator""_LEX_CSTRING`(644ae2aac2bb416c).; |
| 51 | |
| 52 | /** Doc ID is a 8 byte value */ |
| 53 | #define FTS_DOC_ID_LENcxx . . $ `storage/innobase/include/fts0fts.h:53:9`! 8 |
| 54 | |
| 55 | /** The number of fields to sort when we build FT index with |
| 56 | FIC. Three fields are sort: (word, doc_id, position) */ |
| 57 | #define FTS_NUM_FIELDS_SORTcxx . . $ `storage/innobase/include/fts0fts.h:57:9`! 3 |
| 58 | |
| 59 | /** Maximum number of rows in a table, smaller than which, we will |
| 60 | optimize using a 4 byte Doc ID for FIC merge sort to reduce sort size */ |
| 61 | #define MAX_DOC_ID_OPT_VALcxx . . $ `storage/innobase/include/fts0fts.h:61:9`! 1073741824 |
| 62 | |
| 63 | /** Document id type. */ |
| 64 | typedef ib_id_tcxx . . $ ib_id_t# doc_id_tcxx . . $ doc_id_t#; |
| 65 | |
| 66 | /** doc_id_t printf format */ |
| 67 | #define FTS_DOC_ID_FORMATcxx . . $ `storage/innobase/include/fts0fts.h:67:9`! IB_ID_FMTcxx . . $ `storage/innobase/include/univ.i:348:9`! |
| 68 | |
| 69 | /** Convert document id to the InnoDB (BIG ENDIAN) storage format. */ |
| 70 | #define fts_write_doc_idcxx . . $ `storage/innobase/include/fts0fts.h:70:9`!(d, s) mach_write_to_8(d, s) |
| 71 | |
| 72 | /** Read a document id to internal format. */ |
| 73 | #define fts_read_doc_idcxx . . $ `storage/innobase/include/fts0fts.h:73:9`!(s) mach_read_from_8(s) |
| 74 | |
| 75 | /** Bind the doc id to a variable */ |
| 76 | #define fts_bind_doc_idcxx . . $ `storage/innobase/include/fts0fts.h:76:9`!(i, n, v) pars_info_bind_int8_literal(i, n, v) |
| 77 | |
| 78 | /** Defines for FTS query mode, they have the same values as |
| 79 | those defined in mysql file ft_global.h */ |
| 80 | #define FTS_NLcxx . . $ `storage/innobase/include/fts0fts.h:80:9`! 0 |
| 81 | #define FTS_BOOLcxx . . $ `storage/innobase/include/fts0fts.h:81:9`! 1 |
| 82 | #define FTS_SORTEDcxx . . $ `storage/innobase/include/fts0fts.h:82:9`! 2 |
| 83 | #define FTS_EXPANDcxx . . $ `storage/innobase/include/fts0fts.h:83:9`! 4 |
| 84 | #define FTS_NO_RANKINGcxx . . $ `storage/innobase/include/fts0fts.h:84:9`! 8 |
| 85 | #define FTS_PROXIMITYcxx . . $ `storage/innobase/include/fts0fts.h:85:9`! 16 |
| 86 | #define FTS_PHRASEcxx . . $ `storage/innobase/include/fts0fts.h:86:9`! 32 |
| 87 | #define FTS_OPT_RANKINGcxx . . $ `storage/innobase/include/fts0fts.h:87:9`! 64 |
| 88 | |
| 89 | #define FTS_INDEX_TABLE_IND_NAMEcxx . . $ `storage/innobase/include/fts0fts.h:89:9`! "FTS_INDEX_TABLE_IND" |
| 90 | |
| 91 | /** The number of FTS index partitions for a fulltext idnex */ |
| 92 | #define FTS_NUM_AUX_INDEXcxx . . $ `storage/innobase/include/fts0fts.h:92:9`! 6 |
| 93 | |
| 94 | /** Threshold where our optimize thread automatically kicks in */ |
| 95 | #define FTS_OPTIMIZE_THRESHOLDcxx . . $ `storage/innobase/include/fts0fts.h:95:9`! 10000000 |
| 96 | |
| 97 | /** Maximum possible Fulltext word length in bytes (assuming mbmaxlen=4) */ |
| 98 | #define FTS_MAX_WORD_LENcxx . . $ `storage/innobase/include/fts0fts.h:98:9`! (HA_FT_MAXCHARLENcxx . . $ `include/ft_global.h:32:9`! * 4) |
| 99 | |
| 100 | /** Maximum possible Fulltext word length (in characters) */ |
| 101 | #define FTS_MAX_WORD_LEN_IN_CHARcxx . . $ `storage/innobase/include/fts0fts.h:101:9`! HA_FT_MAXCHARLENcxx . . $ `include/ft_global.h:32:9`! |
| 102 | |
| 103 | /** Number of columns in FTS AUX Tables */ |
| 104 | #define FTS_DELETED_TABLE_NUM_COLScxx . . $ `storage/innobase/include/fts0fts.h:104:9`! 1 |
| 105 | #define FTS_CONFIG_TABLE_NUM_COLScxx . . $ `storage/innobase/include/fts0fts.h:105:9`! 2 |
| 106 | #define FTS_AUX_INDEX_TABLE_NUM_COLScxx . . $ `storage/innobase/include/fts0fts.h:106:9`! 5 |
| 107 | |
| 108 | /** DELETED_TABLE(doc_id BIGINT UNSIGNED) */ |
| 109 | #define FTS_DELETED_TABLE_COL_LENcxx . . $ `storage/innobase/include/fts0fts.h:109:9`! 8 |
| 110 | /** CONFIG_TABLE(key CHAR(50), value CHAR(200)) */ |
| 111 | #define FTS_CONFIG_TABLE_KEY_COL_LENcxx . . $ `storage/innobase/include/fts0fts.h:111:9`! 50 |
| 112 | #define FTS_CONFIG_TABLE_VALUE_COL_LENcxx . . $ `storage/innobase/include/fts0fts.h:112:9`! 200 |
| 113 | |
| 114 | #define FTS_INDEX_FIRST_DOC_ID_LENcxx . . $ `storage/innobase/include/fts0fts.h:114:9`! 8 |
| 115 | #define FTS_INDEX_LAST_DOC_ID_LENcxx . . $ `storage/innobase/include/fts0fts.h:115:9`! 8 |
| 116 | #define FTS_INDEX_DOC_COUNT_LENcxx . . $ `storage/innobase/include/fts0fts.h:116:9`! 4 |
| 117 | /* BLOB COLUMN, 0 means VARIABLE SIZE */ |
| 118 | #define FTS_INDEX_ILIST_LENcxx . . $ `storage/innobase/include/fts0fts.h:118:9`! 0 |
| 119 | |
| 120 | |
| 121 | /** Variable specifying the FTS parallel sort degree */ |
| 122 | extern ulong fts_sort_pll_degreecxx . . $ fts_sort_pll_degree.; |
| 123 | |
| 124 | /** Variable specifying the number of word to optimize for each optimize table |
| 125 | call */ |
| 126 | extern ulong fts_num_word_optimizecxx . . $ fts_num_word_optimize.; |
| 127 | |
| 128 | /** Variable specifying whether we do additional FTS diagnostic printout |
| 129 | in the log */ |
| 130 | extern char fts_enable_diag_printcxx . . $ fts_enable_diag_print.; |
| 131 | |
| 132 | /** FTS rank type, which will be between 0 .. 1 inclusive */ |
| 133 | typedef float fts_rank_tcxx . . $ fts_rank_t#; |
| 134 | |
| 135 | /** Type of a row during a transaction. FTS_NOTHING means the row can be |
| 136 | forgotten from the FTS system's POV, FTS_INVALID is an internal value used |
| 137 | to mark invalid states. |
| 138 | |
| 139 | NOTE: Do not change the order or value of these, fts_trx_row_get_new_state |
| 140 | depends on them being exactly as they are. */ |
| 141 | enum fts_row_statecxx . . $ fts_row_state# { |
| 142 | FTS_INSERTcxx . . $ FTS_INSERT. = 0, |
| 143 | FTS_MODIFYcxx . . $ FTS_MODIFY., |
| 144 | FTS_DELETEcxx . . $ FTS_DELETE., |
| 145 | FTS_NOTHINGcxx . . $ FTS_NOTHING., |
| 146 | FTS_INVALIDcxx . . $ FTS_INVALID. |
| 147 | }; |
| 148 | |
| 149 | /** The FTS table types. */ |
| 150 | enum fts_table_type_tcxx . . $ fts_table_type_t# { |
| 151 | FTS_INDEX_TABLEcxx . . $ FTS_INDEX_TABLE., /*!< FTS auxiliary table that is |
| 152 | specific to a particular FTS index |
| 153 | on a table */ |
| 154 | |
| 155 | FTS_COMMON_TABLEcxx . . $ FTS_COMMON_TABLE. /*!< FTS auxiliary table that is common |
| 156 | for all FTS index on a table */ |
| 157 | }; |
| 158 | |
| 159 | struct fts_doc_tcxx . . $ fts_doc_t#; |
| 160 | struct fts_cache_tcxx . . $ fts_cache_t#; |
| 161 | struct fts_token_tcxx . . $ fts_token_t#; |
| 162 | struct fts_doc_ids_tcxx . . $ fts_doc_ids_t#; |
| 163 | struct fts_index_cache_tcxx . . $ fts_index_cache_t#; |
| 164 | |
| 165 | /** Compare two DOC_ID. */ |
| 166 | int fts_doc_id_cmpcxx . . $ fts_doc_id_cmp(9148c8c3ff42c9d8).(const void *p1, const void *p2) |
| 167 | __attribute__((nonnull, warn_unused_result)); |
| 168 | |
| 169 | /** Initialize the "fts_table" for internal query into FTS auxiliary |
| 170 | tables */ |
| 171 | #define FTS_INIT_FTS_TABLEcxx . . $ `storage/innobase/include/fts0fts.h:171:9`!(fts_table, m_suffix, m_type, m_table)\ |
| 172 | do { \ |
| 173 | (fts_table)->suffix = m_suffix; \ |
| 174 | (fts_table)->type = m_type; \ |
| 175 | (fts_table)->table_id = m_table->id; \ |
| 176 | (fts_table)->table = m_table; \ |
| 177 | } while (0); |
| 178 | |
| 179 | #define FTS_INIT_INDEX_TABLEcxx . . $ `storage/innobase/include/fts0fts.h:179:9`!(fts_table, m_suffix, m_type, m_index)\ |
| 180 | do { \ |
| 181 | (fts_table)->suffix = m_suffix; \ |
| 182 | (fts_table)->type = m_type; \ |
| 183 | (fts_table)->table_id = m_index->table->id; \ |
| 184 | (fts_table)->table = m_index->table; \ |
| 185 | (fts_table)->index_id = m_index->id; \ |
| 186 | } while (0); |
| 187 | |
| 188 | /** Information about changes in a single transaction affecting |
| 189 | the FTS system. */ |
| 190 | struct fts_trx_tcxx . . $ fts_trx_t# { |
| 191 | trx_tcxx . . $ trx_t#* trxcxx . . $ fts_trx_t#trx.; /*!< InnoDB transaction */ |
| 192 | |
| 193 | ib_vector_tcxx . . $ ib_vector_t#* savepointscxx . . $ fts_trx_t#savepoints.; /*!< Active savepoints, must have at |
| 194 | least one element, the implied |
| 195 | savepoint */ |
| 196 | ib_vector_tcxx . . $ ib_vector_t#* last_stmtcxx . . $ fts_trx_t#last_stmt.; /*!< last_stmt */ |
| 197 | |
| 198 | mem_heap_tcxx . . $ mem_heap_t#* heapcxx . . $ fts_trx_t#heap.; /*!< heap */ |
| 199 | }; |
| 200 | |
| 201 | /** Information required for transaction savepoint handling. */ |
| 202 | struct fts_savepoint_tcxx . . $ fts_savepoint_t# { |
| 203 | const void* namecxx . . $ fts_savepoint_t#name.; /*!< First entry is always NULL, the |
| 204 | default instance. Otherwise the |
| 205 | savepoint */ |
| 206 | |
| 207 | ib_rbt_tcxx . . $ ib_rbt_t#* tablescxx . . $ fts_savepoint_t#tables.; /*!< Modified FTS tables */ |
| 208 | }; |
| 209 | |
| 210 | /** Information about changed rows in a transaction for a single table. */ |
| 211 | struct fts_trx_table_tcxx . . $ fts_trx_table_t# { |
| 212 | dict_table_tcxx . . $ dict_table_t#* tablecxx . . $ fts_trx_table_t#table.; /*!< table */ |
| 213 | |
| 214 | fts_trx_tcxx . . $ fts_trx_t#* fts_trxcxx . . $ fts_trx_table_t#fts_trx.; /*!< link to parent */ |
| 215 | |
| 216 | ib_rbt_tcxx . . $ ib_rbt_t#* rowscxx . . $ fts_trx_table_t#rows.; /*!< rows changed; indexed by doc-id, |
| 217 | cells are fts_trx_row_t* */ |
| 218 | |
| 219 | fts_doc_ids_tcxx . . $ fts_doc_ids_t#* added_doc_idscxx . . $ fts_trx_table_t#added_doc_ids.; /*!< list of added doc ids (NULL until |
| 220 | the first addition) */ |
| 221 | |
| 222 | /*!< for adding doc ids */ |
| 223 | que_tcxx . . $ que_t#* docs_added_graphcxx . . $ fts_trx_table_t#docs_added_graph.; |
| 224 | }; |
| 225 | |
| 226 | /** Information about one changed row in a transaction. */ |
| 227 | struct fts_trx_row_tcxx . . $ fts_trx_row_t# { |
| 228 | doc_id_tcxx . . $ doc_id_t# doc_idcxx . . $ fts_trx_row_t#doc_id.; /*!< Id of the ins/upd/del document */ |
| 229 | |
| 230 | fts_row_statecxx . . $ fts_row_state# statecxx . . $ fts_trx_row_t#state.; /*!< state of the row */ |
| 231 | |
| 232 | ib_vector_tcxx . . $ ib_vector_t#* fts_indexescxx . . $ fts_trx_row_t#fts_indexes.; /*!< The indexes that are affected */ |
| 233 | }; |
| 234 | |
| 235 | /** List of document ids that were added during a transaction. This |
| 236 | list is passed on to a background 'Add' thread and OPTIMIZE, so it |
| 237 | needs its own memory heap. */ |
| 238 | struct fts_doc_ids_tcxx . . $ fts_doc_ids_t# { |
| 239 | ib_vector_tcxx . . $ ib_vector_t#* doc_idscxx . . $ fts_doc_ids_t#doc_ids.; /*!< document ids (each element is |
| 240 | of type doc_id_t). */ |
| 241 | |
| 242 | ib_alloc_tcxx . . $ ib_alloc_t#* self_heapcxx . . $ fts_doc_ids_t#self_heap.; /*!< Allocator used to create an |
| 243 | instance of this type and the |
| 244 | doc_ids vector */ |
| 245 | }; |
| 246 | |
| 247 | // FIXME: Get rid of this if possible. |
| 248 | /** Since MySQL's character set support for Unicode is woefully inadequate |
| 249 | (it supports basic operations like isalpha etc. only for 8-bit characters), |
| 250 | we have to implement our own. We use UTF-16 without surrogate processing |
| 251 | as our in-memory format. This typedef is a single such character. */ |
| 252 | typedef unsigned short ib_uc_tcxx . . $ ib_uc_t#; |
| 253 | |
| 254 | /** An UTF-16 ro UTF-8 string. */ |
| 255 | struct fts_string_tcxx . . $ fts_string_t# { |
| 256 | bytecxx . . $ byte#* f_strcxx . . $ fts_string_t#f_str.; /*!< string, not necessary terminated in |
| 257 | any way */ |
| 258 | ulintcxx . . $ ulint# f_lencxx . . $ fts_string_t#f_len.; /*!< Length of the string in bytes */ |
| 259 | ulintcxx . . $ ulint# f_n_charcxx . . $ fts_string_t#f_n_char.; /*!< Number of characters */ |
| 260 | }; |
| 261 | |
| 262 | /** Query ranked doc ids. */ |
| 263 | struct fts_ranking_tcxx . . $ fts_ranking_t# { |
| 264 | doc_id_tcxx . . $ doc_id_t# doc_idcxx . . $ fts_ranking_t#doc_id.; /*!< Document id */ |
| 265 | |
| 266 | fts_rank_tcxx . . $ fts_rank_t# rankcxx . . $ fts_ranking_t#rank.; /*!< Rank is between 0 .. 1 */ |
| 267 | |
| 268 | bytecxx . . $ byte#* wordscxx . . $ fts_ranking_t#words.; /*!< this contains the words |
| 269 | that were queried |
| 270 | and found in this document */ |
| 271 | ulintcxx . . $ ulint# words_lencxx . . $ fts_ranking_t#words_len.; /*!< words len */ |
| 272 | }; |
| 273 | |
| 274 | /** Query result. */ |
| 275 | struct fts_result_tcxx . . $ fts_result_t# { |
| 276 | ib_rbt_node_tcxx . . $ ib_rbt_node_t#* currentcxx . . $ fts_result_t#current.; /*!< Current element */ |
| 277 | |
| 278 | ib_rbt_tcxx . . $ ib_rbt_t#* rankings_by_idcxx . . $ fts_result_t#rankings_by_id.; /*!< RB tree of type fts_ranking_t |
| 279 | indexed by doc id */ |
| 280 | ib_rbt_tcxx . . $ ib_rbt_t#* rankings_by_rankcxx . . $ fts_result_t#rankings_by_rank.;/*!< RB tree of type fts_ranking_t |
| 281 | indexed by rank */ |
| 282 | }; |
| 283 | |
| 284 | /** This is used to generate the FTS auxiliary table name, we need the |
| 285 | table id and the index id to generate the column specific FTS auxiliary |
| 286 | table name. */ |
| 287 | struct fts_table_tcxx . . $ fts_table_t# { |
| 288 | fts_table_type_tcxx . . $ fts_table_type_t# |
| 289 | typecxx . . $ fts_table_t#type.; /*!< The auxiliary table type */ |
| 290 | |
| 291 | table_id_tcxx . . $ table_id_t# table_idcxx . . $ fts_table_t#table_id.; /*!< The table id */ |
| 292 | |
| 293 | index_id_tcxx . . $ index_id_t# index_idcxx . . $ fts_table_t#index_id.; /*!< The index id */ |
| 294 | |
| 295 | const char* suffixcxx . . $ fts_table_t#suffix.; /*!< The suffix of the fts auxiliary |
| 296 | table name, can be NULL, not used |
| 297 | everywhere (yet) */ |
| 298 | const dict_table_tcxx . . $ dict_table_t#* |
| 299 | tablecxx . . $ fts_table_t#table.; /*!< Parent table */ |
| 300 | CHARSET_INFOcxx . . $ CHARSET_INFO#* charsetcxx . . $ fts_table_t#charset.; /*!< charset info if it is for FTS |
| 301 | index auxiliary table */ |
| 302 | }; |
| 303 | |
| 304 | /** The state of the FTS sub system. */ |
| 305 | class fts_tcxx . . $ fts_t# { |
| 306 | public: |
| 307 | /** fts_t constructor. |
| 308 | @param[in] table table with FTS indexes |
| 309 | @param[in,out] heap memory heap where 'this' is stored */ |
| 310 | fts_tcxx . . $ fts_t#fts_t(ec6904ae8cee4e7d).( |
| 311 | const dict_table_tcxx . . $ dict_table_t#* table, |
| 312 | mem_heap_tcxx . . $ mem_heap_t#* heap); |
| 313 | |
| 314 | /** fts_t destructor. */ |
| 315 | ~cxx . . $ fts_t#`~fts_t`(49f6e7a06ebc5aa8).fts_tcxx . . $ fts_t#(); |
| 316 | |
| 317 | /** Whether the ADDED table record sync-ed after crash recovery */ |
| 318 | unsigned added_syncedcxx . . $ fts_t#added_synced.:1; |
| 319 | /** Whether the table holds dict_sys.latch */ |
| 320 | unsigned dict_lockedcxx . . $ fts_t#dict_locked.:1; |
| 321 | |
| 322 | /** Work queue for scheduling jobs for the FTS 'Add' thread, or NULL |
| 323 | if the thread has not yet been created. Each work item is a |
| 324 | fts_trx_doc_ids_t*. */ |
| 325 | ib_wqueue_tcxx . . $ ib_wqueue_t#* add_wqcxx . . $ fts_t#add_wq.; |
| 326 | |
| 327 | /** FTS memory buffer for this table, or NULL if the table has no FTS |
| 328 | index. */ |
| 329 | fts_cache_tcxx . . $ fts_cache_t#* cachecxx . . $ fts_t#cache.; |
| 330 | |
| 331 | /** FTS doc id hidden column number in the CLUSTERED index. */ |
| 332 | ulintcxx . . $ ulint# doc_colcxx . . $ fts_t#doc_col.; |
| 333 | |
| 334 | /** Vector of FTS indexes, this is mainly for caching purposes. */ |
| 335 | ib_vector_tcxx . . $ ib_vector_t#* indexescxx . . $ fts_t#indexes.; |
| 336 | |
| 337 | /** Whether the table exists in fts_optimize_wq; |
| 338 | protected by fts_optimize_wq mutex */ |
| 339 | bool in_queuecxx . . $ fts_t#in_queue.; |
| 340 | |
| 341 | /** Whether the sync message exists in fts_optimize_wq; |
| 342 | protected by fts_optimize_wq mutex */ |
| 343 | bool sync_messagecxx . . $ fts_t#sync_message.; |
| 344 | |
| 345 | /** Heap for fts_t allocation. */ |
| 346 | mem_heap_tcxx . . $ mem_heap_t#* fts_heapcxx . . $ fts_t#fts_heap.; |
| 347 | }; |
| 348 | |
| 349 | struct fts_stopword_tcxx . . $ fts_stopword_t#; |
| 350 | |
| 351 | /** status bits for fts_stopword_t status field. */ |
| 352 | #define STOPWORD_NOT_INITcxx . . $ `storage/innobase/include/fts0fts.h:352:9`! 0x1 |
| 353 | #define STOPWORD_OFFcxx . . $ `storage/innobase/include/fts0fts.h:353:9`! 0x2 |
| 354 | #define STOPWORD_FROM_DEFAULTcxx . . $ `storage/innobase/include/fts0fts.h:354:9`! 0x4 |
| 355 | #define STOPWORD_USER_TABLEcxx . . $ `storage/innobase/include/fts0fts.h:355:9`! 0x8 |
| 356 | |
| 357 | extern const char* fts_default_stopwordcxx . . $ fts_default_stopword.[]; |
| 358 | |
| 359 | /** Variable specifying the maximum FTS cache size for each table */ |
| 360 | extern Atomic_relaxedcxx . . $ Atomic_relaxed#<size_t> fts_max_cache_sizecxx . . $ fts_max_cache_size.; |
| 361 | |
| 362 | /** Variable specifying the total memory allocated for FTS cache */ |
| 363 | extern Atomic_relaxedcxx . . $ Atomic_relaxed#<size_t> fts_max_total_cache_sizecxx . . $ fts_max_total_cache_size.; |
| 364 | |
| 365 | /** Variable specifying the FTS result cache limit for each query */ |
| 366 | extern size_t fts_result_cache_limitcxx . . $ fts_result_cache_limit.; |
| 367 | |
| 368 | /** Variable specifying the maximum FTS max token size */ |
| 369 | extern ulong fts_max_token_sizecxx . . $ fts_max_token_size.; |
| 370 | |
| 371 | /** Variable specifying the minimum FTS max token size */ |
| 372 | extern ulong fts_min_token_sizecxx . . $ fts_min_token_size.; |
| 373 | |
| 374 | /** Whether the total memory used for FTS cache is exhausted, and we will |
| 375 | need a sync to free some memory */ |
| 376 | extern bool fts_need_synccxx . . $ fts_need_sync.; |
| 377 | |
| 378 | /******************************************************************//** |
| 379 | Create a FTS cache. */ |
| 380 | fts_cache_tcxx . . $ fts_cache_t#* |
| 381 | fts_cache_createcxx . . $ fts_cache_create(c76bb1a6a133c9a9).( |
| 382 | /*=============*/ |
| 383 | dict_table_tcxx . . $ dict_table_t#* table); /*!< table owns the FTS cache */ |
| 384 | |
| 385 | /******************************************************************//** |
| 386 | Create a FTS index cache. |
| 387 | @return Index Cache */ |
| 388 | fts_index_cache_tcxx . . $ fts_index_cache_t#* |
| 389 | fts_cache_index_cache_createcxx . . $ fts_cache_index_cache_create(82ae79fab803cc60).( |
| 390 | /*=========================*/ |
| 391 | dict_table_tcxx . . $ dict_table_t#* table, /*!< in: table with FTS index */ |
| 392 | dict_index_tcxx . . $ dict_index_t#* index); /*!< in: FTS index */ |
| 393 | |
| 394 | /******************************************************************//** |
| 395 | Get the next available document id. This function creates a new |
| 396 | transaction to generate the document id. |
| 397 | @return DB_SUCCESS if OK */ |
| 398 | dberr_tcxx . . $ dberr_t# |
| 399 | fts_get_next_doc_idcxx . . $ fts_get_next_doc_id(d0d11ed542405b76).( |
| 400 | /*================*/ |
| 401 | const dict_table_tcxx . . $ dict_table_t#* table, /*!< in: table */ |
| 402 | doc_id_tcxx . . $ doc_id_t#* doc_id);/*!< out: new document id */ |
| 403 | |
| 404 | /******************************************************************//** |
| 405 | Create a new fts_doc_ids_t. |
| 406 | @return new fts_doc_ids_t. */ |
| 407 | fts_doc_ids_tcxx . . $ fts_doc_ids_t#* |
| 408 | fts_doc_ids_createcxx . . $ fts_doc_ids_create(4594ecb8a45ca642).(void); |
| 409 | /*=====================*/ |
| 410 | |
| 411 | /** Free fts_doc_ids_t */ |
| 412 | inline void fts_doc_ids_freecxx . . $ fts_doc_ids_free(124bf5ac78dcdafb).(fts_doc_ids_tcxx . . $ fts_doc_ids_t#* doc_ids) |
| 413 | { |
| 414 | mem_heap_freecxx . . $ mem_heap_free(5231cf397463bfab).(static_cast<mem_heap_tcxx . . $ mem_heap_t#*>(doc_ids->self_heapcxx . . $ fts_doc_ids_t#self_heap.->argcxx . . $ ib_alloc_t#arg.)); |
| 415 | } |
| 416 | |
| 417 | /** Sort an array of doc_id */ |
| 418 | void fts_doc_ids_sortcxx . . $ fts_doc_ids_sort(289ab18152974964).(ib_vector_tcxx . . $ ib_vector_t# *doc_ids); |
| 419 | |
| 420 | /******************************************************************//** |
| 421 | Notify the FTS system about an operation on an FTS-indexed table. */ |
| 422 | void |
| 423 | fts_trx_add_opcxx . . $ fts_trx_add_op(ad5c829346a366d8).( |
| 424 | /*===========*/ |
| 425 | trx_tcxx . . $ trx_t#* trx, /*!< in: InnoDB transaction */ |
| 426 | dict_table_tcxx . . $ dict_table_t#* table, /*!< in: table */ |
| 427 | doc_id_tcxx . . $ doc_id_t# doc_id, /*!< in: doc id */ |
| 428 | fts_row_statecxx . . $ fts_row_state# state, /*!< in: state of the row */ |
| 429 | ib_vector_tcxx . . $ ib_vector_t#* fts_indexes); /*!< in: FTS indexes affected |
| 430 | (NULL=all) */ |
| 431 | |
| 432 | /******************************************************************//** |
| 433 | Free an FTS trx. */ |
| 434 | void |
| 435 | fts_trx_freecxx . . $ fts_trx_free(cc315505f4a81e6f).( |
| 436 | /*=========*/ |
| 437 | fts_trx_tcxx . . $ fts_trx_t#* fts_trx); /*!< in, own: FTS trx */ |
| 438 | |
| 439 | /** Creates the common auxiliary tables needed for supporting an FTS index |
| 440 | on the given table. |
| 441 | The following tables are created. |
| 442 | CREATE TABLE $FTS_PREFIX_DELETED |
| 443 | (doc_id BIGINT UNSIGNED, UNIQUE CLUSTERED INDEX on doc_id) |
| 444 | CREATE TABLE $FTS_PREFIX_DELETED_CACHE |
| 445 | (doc_id BIGINT UNSIGNED, UNIQUE CLUSTERED INDEX on doc_id) |
| 446 | CREATE TABLE $FTS_PREFIX_BEING_DELETED |
| 447 | (doc_id BIGINT UNSIGNED, UNIQUE CLUSTERED INDEX on doc_id) |
| 448 | CREATE TABLE $FTS_PREFIX_BEING_DELETED_CACHE |
| 449 | (doc_id BIGINT UNSIGNED, UNIQUE CLUSTERED INDEX on doc_id) |
| 450 | CREATE TABLE $FTS_PREFIX_CONFIG |
| 451 | (key CHAR(50), value CHAR(200), UNIQUE CLUSTERED INDEX on key) |
| 452 | @param[in,out] trx transaction |
| 453 | @param[in] table table with FTS index |
| 454 | @param[in] skip_doc_id_index Skip index on doc id |
| 455 | @return DB_SUCCESS if succeed */ |
| 456 | dberr_tcxx . . $ dberr_t# |
| 457 | fts_create_common_tablescxx . . $ fts_create_common_tables(dfeb38566238d857).( |
| 458 | trx_tcxx . . $ trx_t#* trx, |
| 459 | dict_table_tcxx . . $ dict_table_t#* table, |
| 460 | bool skip_doc_id_index) |
| 461 | MY_ATTRIBUTEcxx . . $ `storage/innobase/include/univ.i:162:11`!((nonnull, warn_unused_result)); |
| 462 | /** Creates the column specific ancillary tables needed for supporting an |
| 463 | FTS index on the given table. |
| 464 | |
| 465 | All FTS AUX Index tables have the following schema. |
| 466 | CREAT TABLE $FTS_PREFIX_INDEX_[1-6]( |
| 467 | word VARCHAR(FTS_MAX_WORD_LEN), |
| 468 | first_doc_id INT NOT NULL, |
| 469 | last_doc_id UNSIGNED NOT NULL, |
| 470 | doc_count UNSIGNED INT NOT NULL, |
| 471 | ilist VARBINARY NOT NULL, |
| 472 | UNIQUE CLUSTERED INDEX ON (word, first_doc_id)) |
| 473 | @param[in,out] trx dictionary transaction |
| 474 | @param[in] index fulltext index |
| 475 | @param[in] id table id |
| 476 | @return DB_SUCCESS or error code */ |
| 477 | dberr_tcxx . . $ dberr_t# |
| 478 | fts_create_index_tablescxx . . $ fts_create_index_tables(e6cd0ad941165777).(trx_tcxx . . $ trx_t#* trx, const dict_index_tcxx . . $ dict_index_t#* index, table_id_tcxx . . $ table_id_t# id) |
| 479 | MY_ATTRIBUTEcxx . . $ `storage/innobase/include/univ.i:162:11`!((nonnull, warn_unused_result)); |
| 480 | /******************************************************************//** |
| 481 | Add the FTS document id hidden column. */ |
| 482 | void |
| 483 | fts_add_doc_id_columncxx . . $ fts_add_doc_id_column(f54c2afd6563a66e).( |
| 484 | /*==================*/ |
| 485 | dict_table_tcxx . . $ dict_table_t#* table, /*!< in/out: Table with FTS index */ |
| 486 | mem_heap_tcxx . . $ mem_heap_t#* heap); /*!< in: temporary memory heap, or NULL */ |
| 487 | |
| 488 | /** Lock the internal FTS_ tables for an index, before fts_drop_index_tables(). |
| 489 | @param trx transaction |
| 490 | @param index fulltext index */ |
| 491 | dberr_tcxx . . $ dberr_t# fts_lock_index_tablescxx . . $ fts_lock_index_tables(816eed68966817f0).(trx_tcxx . . $ trx_t# *trx, const dict_index_tcxx . . $ dict_index_t# &index); |
| 492 | |
| 493 | /** Lock the internal common FTS_ tables, before fts_drop_common_tables(). |
| 494 | @param trx transaction |
| 495 | @param table table containing FULLTEXT INDEX |
| 496 | @return DB_SUCCESS or error code */ |
| 497 | dberr_tcxx . . $ dberr_t# fts_lock_common_tablescxx . . $ fts_lock_common_tables(6fb119b82dd10915).(trx_tcxx . . $ trx_t# *trx, const dict_table_tcxx . . $ dict_table_t# &table); |
| 498 | |
| 499 | /** Lock the internal FTS_ tables for table, before fts_drop_tables(). |
| 500 | @param trx transaction |
| 501 | @param table table containing FULLTEXT INDEX |
| 502 | @return DB_SUCCESS or error code */ |
| 503 | dberr_tcxx . . $ dberr_t# fts_lock_tablescxx . . $ fts_lock_tables(6fb119b82dd10915).(trx_tcxx . . $ trx_t# *trx, const dict_table_tcxx . . $ dict_table_t# &table); |
| 504 | |
| 505 | /** Drop the internal FTS_ tables for table. |
| 506 | @param trx transaction |
| 507 | @param table table containing FULLTEXT INDEX |
| 508 | @return DB_SUCCESS or error code */ |
| 509 | dberr_tcxx . . $ dberr_t# fts_drop_tablescxx . . $ fts_drop_tables(6fb119b82dd10915).(trx_tcxx . . $ trx_t# *trx, const dict_table_tcxx . . $ dict_table_t# &table); |
| 510 | |
| 511 | /******************************************************************//** |
| 512 | The given transaction is about to be committed; do whatever is necessary |
| 513 | from the FTS system's POV. |
| 514 | @return DB_SUCCESS or error code */ |
| 515 | dberr_tcxx . . $ dberr_t# |
| 516 | fts_commitcxx . . $ fts_commit(fa66d1d27bf62ad6).( |
| 517 | /*=======*/ |
| 518 | trx_tcxx . . $ trx_t#* trx) /*!< in: transaction */ |
| 519 | MY_ATTRIBUTEcxx . . $ `storage/innobase/include/univ.i:162:11`!((warn_unused_result)); |
| 520 | |
| 521 | /** FTS Query entry point. |
| 522 | @param[in,out] trx transaction |
| 523 | @param[in] index fts index to search |
| 524 | @param[in] flags FTS search mode |
| 525 | @param[in] query_str FTS query |
| 526 | @param[in] query_len FTS query string len in bytes |
| 527 | @param[in,out] result result doc ids |
| 528 | @return DB_SUCCESS if successful otherwise error code */ |
| 529 | dberr_tcxx . . $ dberr_t# |
| 530 | fts_querycxx . . $ fts_query(2c3b2f1c6b44f278).( |
| 531 | trx_tcxx . . $ trx_t#* trx, |
| 532 | dict_index_tcxx . . $ dict_index_t#* index, |
| 533 | uint flags, |
| 534 | const bytecxx . . $ byte#* query_str, |
| 535 | ulintcxx . . $ ulint# query_len, |
| 536 | fts_result_tcxx . . $ fts_result_t#** result) |
| 537 | MY_ATTRIBUTEcxx . . $ `storage/innobase/include/univ.i:162:11`!((warn_unused_result)); |
| 538 | |
| 539 | /******************************************************************//** |
| 540 | Retrieve the FTS Relevance Ranking result for doc with doc_id |
| 541 | @return the relevance ranking value. */ |
| 542 | float |
| 543 | fts_retrieve_rankingcxx . . $ fts_retrieve_ranking(8ca6710c0e8f34e4).( |
| 544 | /*=================*/ |
| 545 | fts_result_tcxx . . $ fts_result_t#* result, /*!< in: FTS result structure */ |
| 546 | doc_id_tcxx . . $ doc_id_t# doc_id); /*!< in: the interested document |
| 547 | doc_id */ |
| 548 | |
| 549 | /******************************************************************//** |
| 550 | FTS Query sort result, returned by fts_query() on fts_ranking_t::rank. */ |
| 551 | void |
| 552 | fts_query_sort_result_on_rankcxx . . $ fts_query_sort_result_on_rank(5fde81836a091328).( |
| 553 | /*==========================*/ |
| 554 | fts_result_tcxx . . $ fts_result_t#* result); /*!< out: result instance |
| 555 | to sort.*/ |
| 556 | |
| 557 | /******************************************************************//** |
| 558 | FTS Query free result, returned by fts_query(). */ |
| 559 | void |
| 560 | fts_query_free_resultcxx . . $ fts_query_free_result(5fde81836a091328).( |
| 561 | /*==================*/ |
| 562 | fts_result_tcxx . . $ fts_result_t#* result); /*!< in: result instance |
| 563 | to free.*/ |
| 564 | |
| 565 | /******************************************************************//** |
| 566 | Extract the doc id from the FTS hidden column. */ |
| 567 | doc_id_tcxx . . $ doc_id_t# |
| 568 | fts_get_doc_id_from_rowcxx . . $ fts_get_doc_id_from_row(beb6da495f0a06c).( |
| 569 | /*====================*/ |
| 570 | dict_table_tcxx . . $ dict_table_t#* table, /*!< in: table */ |
| 571 | dtuple_tcxx . . $ dtuple_t#* row); /*!< in: row whose FTS doc id we |
| 572 | want to extract.*/ |
| 573 | |
| 574 | /** Extract the doc id from the record that belongs to index. |
| 575 | @param[in] rec record containing FTS_DOC_ID |
| 576 | @param[in] index index of rec |
| 577 | @param[in] offsets rec_get_offsets(rec,index) |
| 578 | @return doc id that was extracted from rec */ |
| 579 | doc_id_tcxx . . $ doc_id_t# |
| 580 | fts_get_doc_id_from_reccxx . . $ fts_get_doc_id_from_rec(e491d669e75572c9).( |
| 581 | const rec_tcxx . . $ rec_t#* rec, |
| 582 | const dict_index_tcxx . . $ dict_index_t#* index, |
| 583 | const rec_offscxx . . $ rec_offs#* offsets); |
| 584 | |
| 585 | /** Add new fts doc id to the update vector. |
| 586 | @param[in] table the table that contains the FTS index. |
| 587 | @param[in,out] ufield the fts doc id field in the update vector. |
| 588 | No new memory is allocated for this in this |
| 589 | function. |
| 590 | @param[in,out] next_doc_id the fts doc id that has been added to the |
| 591 | update vector. If 0, a new fts doc id is |
| 592 | automatically generated. The memory provided |
| 593 | for this argument will be used by the update |
| 594 | vector. Ensure that the life time of this |
| 595 | memory matches that of the update vector. |
| 596 | @return the fts doc id used in the update vector */ |
| 597 | doc_id_tcxx . . $ doc_id_t# |
| 598 | fts_update_doc_idcxx . . $ fts_update_doc_id(d63eef30b6f9239b).( |
| 599 | dict_table_tcxx . . $ dict_table_t#* table, |
| 600 | upd_field_tcxx . . $ upd_field_t#* ufield, |
| 601 | doc_id_tcxx . . $ doc_id_t#* next_doc_id); |
| 602 | |
| 603 | /******************************************************************//** |
| 604 | FTS initialize. */ |
| 605 | void |
| 606 | fts_startupcxx . . $ fts_startup(49f6e7a06ebc5aa8).(void); |
| 607 | /*==============*/ |
| 608 | |
| 609 | /******************************************************************//** |
| 610 | Create an instance of fts_t. |
| 611 | @return instance of fts_t */ |
| 612 | fts_tcxx . . $ fts_t#* |
| 613 | fts_createcxx . . $ fts_create(fe68a4a1a2d26818).( |
| 614 | /*=======*/ |
| 615 | dict_table_tcxx . . $ dict_table_t#* table); /*!< out: table with FTS |
| 616 | indexes */ |
| 617 | |
| 618 | /*********************************************************************//** |
| 619 | Run OPTIMIZE on the given table. |
| 620 | @return DB_SUCCESS if all OK */ |
| 621 | dberr_tcxx . . $ dberr_t# |
| 622 | fts_optimize_tablecxx . . $ fts_optimize_table(ef9f137592cf901).( |
| 623 | /*===============*/ |
| 624 | dict_table_tcxx . . $ dict_table_t#* table); /*!< in: table to optimiza */ |
| 625 | |
| 626 | /** Startup the optimize task and create the work queue. */ |
| 627 | void fts_optimize_initcxx . . $ fts_optimize_init(49f6e7a06ebc5aa8).(); |
| 628 | |
| 629 | /****************************************************************//** |
| 630 | Drops index ancillary tables for a FTS index |
| 631 | @return DB_SUCCESS or error code */ |
| 632 | dberr_tcxx . . $ dberr_t# fts_drop_index_tablescxx . . $ fts_drop_index_tables(816eed68966817f0).(trx_tcxx . . $ trx_t# *trx, const dict_index_tcxx . . $ dict_index_t# &index) |
| 633 | MY_ATTRIBUTEcxx . . $ `storage/innobase/include/univ.i:162:11`!((warn_unused_result)); |
| 634 | |
| 635 | /** Add the table to add to the OPTIMIZER's list. |
| 636 | @param[in] table table to add */ |
| 637 | void |
| 638 | fts_optimize_add_tablecxx . . $ fts_optimize_add_table(48b6e9ea9d480c5b).( |
| 639 | dict_table_tcxx . . $ dict_table_t#* table); |
| 640 | |
| 641 | /******************************************************************//** |
| 642 | Remove the table from the OPTIMIZER's list. We do wait for |
| 643 | acknowledgement from the consumer of the message. */ |
| 644 | void |
| 645 | fts_optimize_remove_tablecxx . . $ fts_optimize_remove_table(48b6e9ea9d480c5b).( |
| 646 | /*======================*/ |
| 647 | dict_table_tcxx . . $ dict_table_t#* table); /*!< in: table to remove */ |
| 648 | |
| 649 | /** Shutdown fts optimize thread. */ |
| 650 | void fts_optimize_shutdowncxx . . $ fts_optimize_shutdown(49f6e7a06ebc5aa8).(); |
| 651 | |
| 652 | #ifdef WITH_WSREPcxx . . $ `/build/tmp.NxIY9EeyJN/package/build/include/my_config.h:539:9`! |
| 653 | /** Pause the optimize subsystem. */ |
| 654 | void fts_optimize_pausecxx . . $ fts_optimize_pause(49f6e7a06ebc5aa8).(); |
| 655 | |
| 656 | /** Resume after fts_optimize_pause() */ |
| 657 | void fts_optimize_resumecxx . . $ fts_optimize_resume(49f6e7a06ebc5aa8).(); |
| 658 | #endif |
| 659 | |
| 660 | /** Send sync fts cache for the table. |
| 661 | @param[in] table table to sync */ |
| 662 | void |
| 663 | fts_optimize_request_sync_tablecxx . . $ fts_optimize_request_sync_table(48b6e9ea9d480c5b).( |
| 664 | dict_table_tcxx . . $ dict_table_t#* table); |
| 665 | |
| 666 | /**********************************************************************//** |
| 667 | Take a FTS savepoint. */ |
| 668 | void |
| 669 | fts_savepoint_takecxx . . $ fts_savepoint_take(894628a2c0cf5cf7).( |
| 670 | /*===============*/ |
| 671 | fts_trx_tcxx . . $ fts_trx_t#* fts_trx, /*!< in: fts transaction */ |
| 672 | const void* name); /*!< in: savepoint */ |
| 673 | |
| 674 | /**********************************************************************//** |
| 675 | Refresh last statement savepoint. */ |
| 676 | void |
| 677 | fts_savepoint_laststmt_refreshcxx . . $ fts_savepoint_laststmt_refresh(a6968fd0d8f26912).( |
| 678 | /*===========================*/ |
| 679 | trx_tcxx . . $ trx_t#* trx); /*!< in: transaction */ |
| 680 | |
| 681 | /**********************************************************************//** |
| 682 | Release the savepoint data identified by name. */ |
| 683 | void |
| 684 | fts_savepoint_releasecxx . . $ fts_savepoint_release(29acb21b07ff564d).( |
| 685 | /*==================*/ |
| 686 | trx_tcxx . . $ trx_t#* trx, /*!< in: transaction */ |
| 687 | const void* name); /*!< in: savepoint */ |
| 688 | |
| 689 | /** Clear cache. |
| 690 | @param[in,out] cache fts cache */ |
| 691 | void |
| 692 | fts_cache_clearcxx . . $ fts_cache_clear(5ee1b66d3ff172b9).( |
| 693 | fts_cache_tcxx . . $ fts_cache_t#* cache); |
| 694 | |
| 695 | /*********************************************************************//** |
| 696 | Initialize things in cache. */ |
| 697 | void |
| 698 | fts_cache_initcxx . . $ fts_cache_init(5ee1b66d3ff172b9).( |
| 699 | /*===========*/ |
| 700 | fts_cache_tcxx . . $ fts_cache_t#* cache); /*!< in: cache */ |
| 701 | |
| 702 | /*********************************************************************//** |
| 703 | Rollback to and including savepoint indentified by name. */ |
| 704 | void |
| 705 | fts_savepoint_rollbackcxx . . $ fts_savepoint_rollback(29acb21b07ff564d).( |
| 706 | /*===================*/ |
| 707 | trx_tcxx . . $ trx_t#* trx, /*!< in: transaction */ |
| 708 | const void* name); /*!< in: savepoint */ |
| 709 | |
| 710 | /*********************************************************************//** |
| 711 | Rollback to and including savepoint indentified by name. */ |
| 712 | void |
| 713 | fts_savepoint_rollback_last_stmtcxx . . $ fts_savepoint_rollback_last_stmt(a6968fd0d8f26912).( |
| 714 | /*=============================*/ |
| 715 | trx_tcxx . . $ trx_t#* trx); /*!< in: transaction */ |
| 716 | |
| 717 | /** Run SYNC on the table, i.e., write out data from the cache to the |
| 718 | FTS auxiliary INDEX table and clear the cache at the end. |
| 719 | @param[in,out] table fts table |
| 720 | @param[in] wait whether to wait for existing sync to finish |
| 721 | @return DB_SUCCESS on success, error code on failure. */ |
| 722 | dberr_tcxx . . $ dberr_t# fts_sync_tablecxx . . $ fts_sync_table(28e19ada227580c6).(dict_table_tcxx . . $ dict_table_t#* table, bool wait = true); |
| 723 | |
| 724 | /****************************************************************//** |
| 725 | Create an FTS index cache. */ |
| 726 | CHARSET_INFOcxx . . $ CHARSET_INFO#* |
| 727 | fts_index_get_charsetcxx . . $ fts_index_get_charset(c2ab1446c1ccdbc3).( |
| 728 | /*==================*/ |
| 729 | dict_index_tcxx . . $ dict_index_t#* index); /*!< in: FTS index */ |
| 730 | |
| 731 | /*********************************************************************//** |
| 732 | Get the initial Doc ID by consulting the CONFIG table |
| 733 | @return initial Doc ID */ |
| 734 | doc_id_tcxx . . $ doc_id_t# |
| 735 | fts_init_doc_idcxx . . $ fts_init_doc_id(8b7f25d2756988c8).( |
| 736 | /*============*/ |
| 737 | const dict_table_tcxx . . $ dict_table_t#* table); /*!< in: table */ |
| 738 | |
| 739 | /******************************************************************//** |
| 740 | compare two character string according to their charset. */ |
| 741 | extern |
| 742 | int |
| 743 | innobase_fts_text_cmpcxx . . $ innobase_fts_text_cmp(d8ab2ef60fb48a1f).( |
| 744 | /*==================*/ |
| 745 | const void* cs, /*!< in: Character set */ |
| 746 | const void* p1, /*!< in: key */ |
| 747 | const void* p2); /*!< in: node */ |
| 748 | |
| 749 | /******************************************************************//** |
| 750 | compare two character string according to their charset. */ |
| 751 | extern |
| 752 | int |
| 753 | innobase_fts_text_cmp_prefixcxx . . $ innobase_fts_text_cmp_prefix(d8ab2ef60fb48a1f).( |
| 754 | /*=========================*/ |
| 755 | const void* cs, /*!< in: Character set */ |
| 756 | const void* p1, /*!< in: key */ |
| 757 | const void* p2); /*!< in: node */ |
| 758 | |
| 759 | /*************************************************************//** |
| 760 | Get the next token from the given string and store it in *token. */ |
| 761 | extern |
| 762 | ulintcxx . . $ ulint# |
| 763 | innobase_mysql_fts_get_tokencxx . . $ innobase_mysql_fts_get_token(4272cb42d6a91b21).( |
| 764 | /*=========================*/ |
| 765 | CHARSET_INFOcxx . . $ CHARSET_INFO#* charset, /*!< in: Character set */ |
| 766 | const bytecxx . . $ byte#* start, /*!< in: start of text */ |
| 767 | const bytecxx . . $ byte#* end, /*!< in: one character past |
| 768 | end of text */ |
| 769 | fts_string_tcxx . . $ fts_string_t#* token); /*!< out: token's text */ |
| 770 | |
| 771 | /*************************************************************//** |
| 772 | Get token char size by charset |
| 773 | @return the number of token char size */ |
| 774 | ulintcxx . . $ ulint# |
| 775 | fts_get_token_sizecxx . . $ fts_get_token_size(322a5465f6abb08b).( |
| 776 | /*===============*/ |
| 777 | const CHARSET_INFOcxx . . $ CHARSET_INFO#* cs, /*!< in: Character set */ |
| 778 | const char* token, /*!< in: token */ |
| 779 | ulintcxx . . $ ulint# len); /*!< in: token length */ |
| 780 | |
| 781 | /*************************************************************//** |
| 782 | FULLTEXT tokenizer internal in MYSQL_FTPARSER_SIMPLE_MODE |
| 783 | @return 0 if tokenize sucessfully */ |
| 784 | int |
| 785 | fts_tokenize_document_internalcxx . . $ fts_tokenize_document_internal(14b41928ff349aba).( |
| 786 | /*===========================*/ |
| 787 | MYSQL_FTPARSER_PARAM* param, /*!< in: parser parameter */ |
| 788 | const char* doc, /*!< in: document to tokenize */ |
| 789 | int len); /*!< in: document length */ |
| 790 | |
| 791 | /*********************************************************************//** |
| 792 | Fetch COUNT(*) from specified table. |
| 793 | @return the number of rows in the table */ |
| 794 | ulintcxx . . $ ulint# |
| 795 | fts_get_rows_countcxx . . $ fts_get_rows_count(48c08334a3b8f59b).( |
| 796 | /*===============*/ |
| 797 | fts_table_tcxx . . $ fts_table_t#* fts_table); /*!< in: fts table to read */ |
| 798 | |
| 799 | /*************************************************************//** |
| 800 | Get maximum Doc ID in a table if index "FTS_DOC_ID_INDEX" exists |
| 801 | @return max Doc ID or 0 if index "FTS_DOC_ID_INDEX" does not exist */ |
| 802 | doc_id_tcxx . . $ doc_id_t# |
| 803 | fts_get_max_doc_idcxx . . $ fts_get_max_doc_id(6d9bc5841bb2dc90).( |
| 804 | /*===============*/ |
| 805 | dict_table_tcxx . . $ dict_table_t#* table); /*!< in: user table */ |
| 806 | |
| 807 | /** Check whether a stopword table is in the right format. |
| 808 | @param stopword_table_name table name |
| 809 | @param row_end name of the system-versioning end column, or "value" |
| 810 | @return the stopword column charset |
| 811 | @retval NULL if the table does not exist or qualify */ |
| 812 | CHARSET_INFOcxx . . $ CHARSET_INFO# *fts_valid_stopword_tablecxx . . $ fts_valid_stopword_table(1b637af397c5a6a9).(const char *stopword_table_name, |
| 813 | const char **row_end= NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 814 | |
| 815 | /****************************************************************//** |
| 816 | This function loads specified stopword into FTS cache |
| 817 | @return true if success */ |
| 818 | bool |
| 819 | fts_load_stopwordcxx . . $ fts_load_stopword(8d272bfdcfe80d98).( |
| 820 | /*==============*/ |
| 821 | const dict_table_tcxx . . $ dict_table_t#* |
| 822 | table, /*!< in: Table with FTS */ |
| 823 | trx_tcxx . . $ trx_t#* trx, /*!< in: Transaction */ |
| 824 | const char* session_stopword_table, /*!< in: Session stopword table |
| 825 | name */ |
| 826 | bool stopword_is_on, /*!< in: Whether stopword |
| 827 | option is turned on/off */ |
| 828 | bool reload); /*!< in: Whether it is during |
| 829 | reload of FTS table */ |
| 830 | |
| 831 | /****************************************************************//** |
| 832 | Read the rows from the FTS index |
| 833 | @return DB_SUCCESS if OK */ |
| 834 | dberr_tcxx . . $ dberr_t# |
| 835 | fts_table_fetch_doc_idscxx . . $ fts_table_fetch_doc_ids(26ecccf0bc7bd587).( |
| 836 | /*====================*/ |
| 837 | trx_tcxx . . $ trx_t#* trx, /*!< in: transaction */ |
| 838 | fts_table_tcxx . . $ fts_table_t#* fts_table, /*!< in: aux table */ |
| 839 | fts_doc_ids_tcxx . . $ fts_doc_ids_t#* doc_ids); /*!< in: For collecting |
| 840 | doc ids */ |
| 841 | /****************************************************************//** |
| 842 | This function brings FTS index in sync when FTS index is first |
| 843 | used. There are documents that have not yet sync-ed to auxiliary |
| 844 | tables from last server abnormally shutdown, we will need to bring |
| 845 | such document into FTS cache before any further operations */ |
| 846 | void |
| 847 | fts_init_indexcxx . . $ fts_init_index(91668cf98b8c60bd).( |
| 848 | /*===========*/ |
| 849 | dict_table_tcxx . . $ dict_table_t#* table, /*!< in: Table with FTS */ |
| 850 | bool has_cache_lock); /*!< in: Whether we already |
| 851 | have cache lock */ |
| 852 | /*******************************************************************//** |
| 853 | Add a newly create index in FTS cache */ |
| 854 | void |
| 855 | fts_add_indexcxx . . $ fts_add_index(9872d70ae5b29b4).( |
| 856 | /*==========*/ |
| 857 | dict_index_tcxx . . $ dict_index_t#* index, /*!< FTS index to be added */ |
| 858 | dict_table_tcxx . . $ dict_table_t#* table); /*!< table */ |
| 859 | |
| 860 | /*******************************************************************//** |
| 861 | Drop auxiliary tables related to an FTS index |
| 862 | @return DB_SUCCESS or error number */ |
| 863 | dberr_tcxx . . $ dberr_t# |
| 864 | fts_drop_indexcxx . . $ fts_drop_index(510fc5374aaa8a0).( |
| 865 | /*===========*/ |
| 866 | dict_table_tcxx . . $ dict_table_t#* table, /*!< in: Table where indexes are dropped */ |
| 867 | dict_index_tcxx . . $ dict_index_t#* index, /*!< in: Index to be dropped */ |
| 868 | trx_tcxx . . $ trx_t#* trx); /*!< in: Transaction for the drop */ |
| 869 | |
| 870 | /****************************************************************//** |
| 871 | Rename auxiliary tables for all fts index for a table |
| 872 | @return DB_SUCCESS or error code */ |
| 873 | dberr_tcxx . . $ dberr_t# |
| 874 | fts_rename_aux_tablescxx . . $ fts_rename_aux_tables(88d1e67981df5357).( |
| 875 | /*==================*/ |
| 876 | dict_table_tcxx . . $ dict_table_t#* table, /*!< in: user Table */ |
| 877 | const char* new_name, /*!< in: new table name */ |
| 878 | trx_tcxx . . $ trx_t#* trx); /*!< in: transaction */ |
| 879 | |
| 880 | /*******************************************************************//** |
| 881 | Check indexes in the fts->indexes is also present in index cache and |
| 882 | table->indexes list |
| 883 | @return TRUE if all indexes match */ |
| 884 | iboolcxx . . $ ulint# |
| 885 | fts_check_cached_indexcxx . . $ fts_check_cached_index(6d9bc5841bb2dc90).( |
| 886 | /*===================*/ |
| 887 | dict_table_tcxx . . $ dict_table_t#* table); /*!< in: Table where indexes are dropped */ |
| 888 | |
| 889 | /** Fetch the document from tuple, tokenize the text data and |
| 890 | insert the text data into fts auxiliary table and |
| 891 | its cache. Moreover this tuple fields doesn't contain any information |
| 892 | about externally stored field. This tuple contains data directly |
| 893 | converted from mysql. |
| 894 | @param[in] ftt FTS transaction table |
| 895 | @param[in] doc_id doc id |
| 896 | @param[in] tuple tuple from where data can be retrieved |
| 897 | and tuple should be arranged in table |
| 898 | schema order. */ |
| 899 | void |
| 900 | fts_add_doc_from_tuplecxx . . $ fts_add_doc_from_tuple(492fc64e5486ab7e).( |
| 901 | fts_trx_table_tcxx . . $ fts_trx_table_t#*ftt, |
| 902 | doc_id_tcxx . . $ doc_id_t# doc_id, |
| 903 | const dtuple_tcxx . . $ dtuple_t#* tuple); |
| 904 | |
| 905 | /** Create an FTS trx. |
| 906 | @param[in,out] trx InnoDB Transaction |
| 907 | @return FTS transaction. */ |
| 908 | fts_trx_tcxx . . $ fts_trx_t#* |
| 909 | fts_trx_createcxx . . $ fts_trx_create(df703b980493bf3).( |
| 910 | trx_tcxx . . $ trx_t#* trx); |
| 911 | |
| 912 | /** Clear all fts resources when there is no internal DOC_ID |
| 913 | and there are no new fts index to add. |
| 914 | @param[in,out] table table where fts is to be freed */ |
| 915 | void fts_clear_allcxx . . $ fts_clear_all(48b6e9ea9d480c5b).(dict_table_tcxx . . $ dict_table_t# *table); |
| 916 | |
| 917 | /** Check whether the given name is fts auxiliary table |
| 918 | and fetch the parent table id and index id |
| 919 | @param[in] name table name |
| 920 | @param[in,out] table_id parent table id |
| 921 | @param[in,out] index_id index id |
| 922 | @return true if it is auxilary table */ |
| 923 | bool fts_check_aux_tablecxx . . $ fts_check_aux_table(ddc2e61b0e945862).(const char *name, |
| 924 | table_id_tcxx . . $ table_id_t# *table_id, |
| 925 | index_id_tcxx . . $ index_id_t# *index_id); |
| 926 | |
| 927 | /** Update the last document id. This function could create a new |
| 928 | transaction to update the last document id. |
| 929 | @param table table to be updated |
| 930 | @param doc_id last document id |
| 931 | @param trx update trx or null |
| 932 | @retval DB_SUCCESS if OK */ |
| 933 | dberr_tcxx . . $ dberr_t# |
| 934 | fts_update_sync_doc_idcxx . . $ fts_update_sync_doc_id(8803f3db7a2157e8).(const dict_table_tcxx . . $ dict_table_t# *table, |
| 935 | doc_id_tcxx . . $ doc_id_t# doc_id, |
| 936 | trx_tcxx . . $ trx_t# *trx) |
| 937 | MY_ATTRIBUTEcxx . . $ `storage/innobase/include/univ.i:162:11`!((nonnull(1))); |
| 938 | |
| 939 | /** Sync the table during commit phase |
| 940 | @param[in] table table to be synced */ |
| 941 | void fts_sync_during_ddlcxx . . $ fts_sync_during_ddl(48b6e9ea9d480c5b).(dict_table_tcxx . . $ dict_table_t#* table); |