Skip to content

Commit edb947e

Browse files
MDEV-28730 Remove internal parser usage from InnoDB fts
- Removed fts0sql.cc file. - Removed commented fts funtions - Removed fts_table_t from fts_query_t and fts_optimize_t
1 parent 23883ca commit edb947e

File tree

7 files changed

+48
-941
lines changed

7 files changed

+48
-941
lines changed

storage/innobase/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ SET(INNOBASE_SOURCES
175175
fts/fts0opt.cc
176176
fts/fts0pars.cc
177177
fts/fts0que.cc
178-
fts/fts0sql.cc
179178
fts/fts0tlex.cc
180179
gis/gis0geo.cc
181180
gis/gis0rtree.cc

storage/innobase/fts/fts0fts.cc

Lines changed: 41 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -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
/****************************************************************//**
561601
Create a FTS cache. */
562602
fts_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
/*********************************************************************//**
29902940
fetch and tokenize the document. */
29912941
static
@@ -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

storage/innobase/fts/fts0opt.cc

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,6 @@ struct fts_optimize_t {
138138

139139
char* name_prefix; /*!< FTS table name prefix */
140140

141-
fts_table_t fts_index_table;/*!< Common table definition */
142-
143-
/*!< Common table definition */
144-
fts_table_t fts_common_table;
145-
146141
dict_table_t* table; /*!< Table that has to be queried */
147142

148143
dict_index_t* index; /*!< The FTS index to be optimized */
@@ -1230,18 +1225,10 @@ fts_optimize_create(
12301225
optim->trx = trx_create();
12311226
trx_start_internal(optim->trx);
12321227

1233-
optim->fts_common_table.table_id = table->id;
1234-
optim->fts_common_table.type = FTS_COMMON_TABLE;
1235-
optim->fts_common_table.table = table;
1236-
1237-
optim->fts_index_table.table_id = table->id;
1238-
optim->fts_index_table.type = FTS_INDEX_TABLE;
1239-
optim->fts_index_table.table = table;
1240-
12411228
/* The common prefix for all this parent table's aux tables. */
12421229
char table_id[FTS_AUX_MIN_TABLE_ID_LENGTH];
12431230
const size_t table_id_len = 1
1244-
+ size_t(fts_get_table_id(&optim->fts_common_table, table_id));
1231+
+ size_t(fts_write_object_id(table->id, table_id));
12451232
dict_sys.freeze(SRW_LOCK_CALL);
12461233
/* Include the separator as well. */
12471234
const size_t dbname_len = table->name.dblen() + 1;
@@ -1546,10 +1533,6 @@ fts_optimize_index(
15461533
dberr_t error;
15471534
byte str[FTS_MAX_WORD_LEN + 1];
15481535

1549-
/* Set the current index that we have to optimize. */
1550-
optim->fts_index_table.index_id = index->id;
1551-
optim->fts_index_table.charset = fts_index_get_charset(index);
1552-
15531536
optim->done = FALSE; /* Optimize until !done */
15541537

15551538
/* We need to read the last word optimized so that we start from
@@ -1713,7 +1696,6 @@ fts_optimize_read_deleted_doc_id_snapshot(
17131696

17141697
if (error == DB_SUCCESS) {
17151698

1716-
optim->fts_common_table.suffix = "BEING_DELETED_CACHE";
17171699
/* Read additional doc_ids to delete. */
17181700
error = fts_table_fetch_doc_ids(
17191701
optim->trx, optim->table, "BEING_DELETED_CACHE",

0 commit comments

Comments
 (0)