@@ -557,6 +557,46 @@ fts_cache_init(
557557 }
558558}
559559
560+ /* * Construct the name of an internal FTS table for the given table.
561+ @param[in] fts_table metadata on fulltext-indexed table
562+ @param[out] table_name a name up to MAX_FULL_NAME_LEN
563+ @param[in] dict_locked whether dict_sys.latch is being held */
564+ void fts_get_table_name (const fts_table_t * fts_table, char * table_name,
565+ bool dict_locked)
566+ {
567+ if (!dict_locked) dict_sys.freeze (SRW_LOCK_CALL);
568+ ut_ad (dict_sys.frozen ());
569+ /* Include the separator as well. */
570+ const size_t dbname_len= fts_table->table ->name .dblen () + 1 ;
571+ ut_ad (dbname_len > 1 );
572+ memcpy (table_name, fts_table->table ->name .m_name , dbname_len);
573+ if (!dict_locked) dict_sys.unfreeze ();
574+
575+ memcpy (table_name += dbname_len, " FTS_" , 4 );
576+ table_name += 4 ;
577+ int len;
578+ switch (fts_table->type )
579+ {
580+ case FTS_COMMON_TABLE:
581+ len= fts_write_object_id (fts_table->table_id , table_name);
582+ break ;
583+
584+ case FTS_INDEX_TABLE:
585+ len= fts_write_object_id (fts_table->table_id , table_name);
586+ table_name[len]= ' _' ;
587+ ++len;
588+ len+= fts_write_object_id (fts_table->index_id , table_name + len);
589+ break ;
590+
591+ default : ut_error;
592+ }
593+ ut_a (len >= 16 );
594+ ut_a (len < FTS_AUX_MIN_TABLE_ID_LENGTH);
595+ table_name+= len;
596+ *table_name++= ' _' ;
597+ strcpy (table_name, fts_table->suffix );
598+ }
599+
560600/* ***************************************************************/ /* *
561601Create a FTS cache. */
562602fts_cache_t *
@@ -2690,7 +2730,6 @@ fts_delete(
26902730 fts_trx_table_t *ftt, /* !< in: FTS trx table */
26912731 fts_trx_row_t * row) /* !< in: row */
26922732{
2693- fts_table_t fts_table;
26942733 dict_table_t * table = ftt->table ;
26952734 doc_id_t doc_id = row->doc_id ;
26962735 trx_t * trx = ftt->fts_trx ->trx ;
@@ -2704,8 +2743,6 @@ fts_delete(
27042743
27052744 ut_a (row->state == FTS_DELETE || row->state == FTS_MODIFY);
27062745
2707- FTS_INIT_FTS_TABLE (&fts_table, " DELETED" , FTS_COMMON_TABLE, table);
2708-
27092746 /* It is possible we update a record that has not yet been sync-ed
27102747 into cache from last crash (delete Doc will not initialize the
27112748 sync). Avoid any added counter accounting until the FTS cache
@@ -2899,93 +2936,6 @@ fts_doc_free(
28992936 mem_heap_free (heap);
29002937}
29012938
2902- /* ********************************************************************/ /* *
2903- Callback function for fetch that stores the text of an FTS document,
2904- converting each column to UTF-16.
2905- @return always FALSE */
2906- ibool
2907- fts_query_expansion_fetch_doc (
2908- /* ==========================*/
2909- void * row, /* !< in: sel_node_t* */
2910- void * user_arg) /* !< in: fts_doc_t* */
2911- {
2912- que_node_t * exp;
2913- sel_node_t * node = static_cast <sel_node_t *>(row);
2914- fts_doc_t * result_doc = static_cast <fts_doc_t *>(user_arg);
2915- dfield_t * dfield;
2916- ulint len;
2917- ulint doc_len;
2918- fts_doc_t doc;
2919- CHARSET_INFO* doc_charset = NULL ;
2920- ulint field_no = 0 ;
2921-
2922- len = 0 ;
2923-
2924- fts_doc_init (&doc);
2925- doc.found = TRUE ;
2926-
2927- exp = node->select_list ;
2928- doc_len = 0 ;
2929-
2930- doc_charset = result_doc->charset ;
2931-
2932- /* Copy each indexed column content into doc->text.f_str */
2933- while (exp) {
2934- dfield = que_node_get_val (exp);
2935- len = dfield_get_len (dfield);
2936-
2937- /* NULL column */
2938- if (len == UNIV_SQL_NULL) {
2939- exp = que_node_get_next (exp);
2940- continue ;
2941- }
2942-
2943- if (!doc_charset) {
2944- doc_charset = fts_get_charset (dfield->type .prtype );
2945- }
2946-
2947- doc.charset = doc_charset;
2948-
2949- if (dfield_is_ext (dfield)) {
2950- /* We ignore columns that are stored externally, this
2951- could result in too many words to search */
2952- exp = que_node_get_next (exp);
2953- continue ;
2954- } else {
2955- doc.text .f_n_char = 0 ;
2956-
2957- doc.text .f_str = static_cast <byte*>(
2958- dfield_get_data (dfield));
2959-
2960- doc.text .f_len = len;
2961- }
2962-
2963- if (field_no == 0 ) {
2964- fts_tokenize_document (&doc, result_doc,
2965- result_doc->parser );
2966- } else {
2967- fts_tokenize_document_next (&doc, doc_len, result_doc,
2968- result_doc->parser );
2969- }
2970-
2971- exp = que_node_get_next (exp);
2972-
2973- doc_len += (exp) ? len + 1 : len;
2974-
2975- field_no++;
2976- }
2977-
2978- ut_ad (doc_charset);
2979-
2980- if (!result_doc->charset ) {
2981- result_doc->charset = doc_charset;
2982- }
2983-
2984- fts_doc_free (&doc);
2985-
2986- return (FALSE );
2987- }
2988-
29892939/* ********************************************************************/ /* *
29902940fetch and tokenize the document. */
29912941static
@@ -4455,12 +4405,11 @@ fts_update_max_cache_size(
44554405 fts_sync_t * sync) /* !< in: sync state */
44564406{
44574407 trx_t * trx;
4458- fts_table_t fts_table;
44594408
44604409 trx = trx_create ();
44614410
44624411 /* The size returned is in bytes. */
4463- sync->max_cache_size = fts_get_max_cache_size (trx, &fts_table );
4412+ sync->max_cache_size = fts_get_max_cache_size (trx, sync-> table );
44644413
44654414 fts_sql_commit (trx);
44664415
0 commit comments