mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-35183 ADD FULLTEXT INDEX unnecessarily DROPS FTS COMMON TABLES
- InnoDB fulltext rebuilds the FTS COMMON table while adding the new fulltext index. This can be optimized by avoiding rebuilding the FTS COMMON table in case of FTS COMMON TABLE already exists. Reviewed-by: Marko Mäkelä <marko.makela@mariadb.com>
This commit is contained in:
@@ -784,3 +784,28 @@ f1 MATCH(f1) AGAINST ("test" IN BOOLEAN MODE)
|
|||||||
test 0.000000001885928302414186
|
test 0.000000001885928302414186
|
||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
# End of 10.3 tests
|
# End of 10.3 tests
|
||||||
|
#
|
||||||
|
# MDEV-35183 ADD FULLTEXT INDEX unnecessarily DROPS FTS
|
||||||
|
# COMMON TABLES
|
||||||
|
#
|
||||||
|
CREATE TABLE t1 (
|
||||||
|
ID INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
|
||||||
|
title VARCHAR(200), book VARCHAR(200),
|
||||||
|
FULLTEXT fidx(title)) ENGINE = InnoDB;
|
||||||
|
INSERT INTO t1(title) VALUES('database');
|
||||||
|
ALTER TABLE t1 DROP INDEX fidx;
|
||||||
|
select space into @common_space from information_schema.innodb_sys_tables where name like "test/FTS_%_CONFIG";
|
||||||
|
ALTER TABLE t1 ADD FULLTEXT fidx_1(book);
|
||||||
|
select space=@common_space from information_schema.innodb_sys_tables where name like "test/FTS_%_CONFIG";
|
||||||
|
space=@common_space
|
||||||
|
1
|
||||||
|
SHOW CREATE TABLE t1;
|
||||||
|
Table Create Table
|
||||||
|
t1 CREATE TABLE `t1` (
|
||||||
|
`ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
|
`title` varchar(200) DEFAULT NULL,
|
||||||
|
`book` varchar(200) DEFAULT NULL,
|
||||||
|
PRIMARY KEY (`ID`),
|
||||||
|
FULLTEXT KEY `fidx_1` (`book`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
|
||||||
|
DROP TABLE t1;
|
||||||
|
@@ -803,3 +803,19 @@ SELECT f1, MATCH(f1) AGAINST ("test" IN BOOLEAN MODE) FROM t1;
|
|||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
|
|
||||||
--echo # End of 10.3 tests
|
--echo # End of 10.3 tests
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-35183 ADD FULLTEXT INDEX unnecessarily DROPS FTS
|
||||||
|
--echo # COMMON TABLES
|
||||||
|
--echo #
|
||||||
|
CREATE TABLE t1 (
|
||||||
|
ID INT UNSIGNED AUTO_INCREMENT NOT NULL PRIMARY KEY,
|
||||||
|
title VARCHAR(200), book VARCHAR(200),
|
||||||
|
FULLTEXT fidx(title)) ENGINE = InnoDB;
|
||||||
|
INSERT INTO t1(title) VALUES('database');
|
||||||
|
ALTER TABLE t1 DROP INDEX fidx;
|
||||||
|
select space into @common_space from information_schema.innodb_sys_tables where name like "test/FTS_%_CONFIG";
|
||||||
|
ALTER TABLE t1 ADD FULLTEXT fidx_1(book);
|
||||||
|
select space=@common_space from information_schema.innodb_sys_tables where name like "test/FTS_%_CONFIG";
|
||||||
|
SHOW CREATE TABLE t1;
|
||||||
|
DROP TABLE t1;
|
||||||
|
@@ -6293,6 +6293,7 @@ prepare_inplace_alter_table_dict(
|
|||||||
dberr_t error;
|
dberr_t error;
|
||||||
ulint num_fts_index;
|
ulint num_fts_index;
|
||||||
dict_add_v_col_t* add_v = NULL;
|
dict_add_v_col_t* add_v = NULL;
|
||||||
|
bool fts_instance_created = false;
|
||||||
ha_innobase_inplace_ctx*ctx;
|
ha_innobase_inplace_ctx*ctx;
|
||||||
|
|
||||||
DBUG_ENTER("prepare_inplace_alter_table_dict");
|
DBUG_ENTER("prepare_inplace_alter_table_dict");
|
||||||
@@ -6539,6 +6540,7 @@ new_clustered_failed:
|
|||||||
new_table_name, NULL, n_cols + n_v_cols, n_v_cols,
|
new_table_name, NULL, n_cols + n_v_cols, n_v_cols,
|
||||||
flags, flags2);
|
flags, flags2);
|
||||||
|
|
||||||
|
fts_instance_created = (ctx->new_table->fts != nullptr);
|
||||||
/* The rebuilt indexed_table will use the renamed
|
/* The rebuilt indexed_table will use the renamed
|
||||||
column names. */
|
column names. */
|
||||||
ctx->col_names = NULL;
|
ctx->col_names = NULL;
|
||||||
@@ -6732,6 +6734,7 @@ wrong_column_name:
|
|||||||
ctx->new_table->fts = fts_create(
|
ctx->new_table->fts = fts_create(
|
||||||
ctx->new_table);
|
ctx->new_table);
|
||||||
ctx->new_table->fts->doc_col = fts_doc_id_col;
|
ctx->new_table->fts->doc_col = fts_doc_id_col;
|
||||||
|
fts_instance_created = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if we need to update mtypes of legacy GIS columns.
|
/* Check if we need to update mtypes of legacy GIS columns.
|
||||||
@@ -7228,8 +7231,11 @@ op_ok:
|
|||||||
ctx->trx->commit();
|
ctx->trx->commit();
|
||||||
trx_start_for_ddl(ctx->trx, op);
|
trx_start_for_ddl(ctx->trx, op);
|
||||||
|
|
||||||
if (!ctx->new_table->fts
|
/* If table rebuild happens or fulltext index are
|
||||||
|| ib_vector_size(ctx->new_table->fts->indexes) == 0) {
|
being added when common tables doesn't exist then
|
||||||
|
do create new fulltext common tables else use the
|
||||||
|
existing fulltext common tables */
|
||||||
|
if (fts_instance_created) {
|
||||||
error = fts_create_common_tables(
|
error = fts_create_common_tables(
|
||||||
ctx->trx, ctx->new_table, true);
|
ctx->trx, ctx->new_table, true);
|
||||||
|
|
||||||
@@ -7240,6 +7246,9 @@ op_ok:
|
|||||||
if (error != DB_SUCCESS) {
|
if (error != DB_SUCCESS) {
|
||||||
goto error_handling;
|
goto error_handling;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ib_vector_size(ctx->new_table->fts->indexes)) {
|
||||||
|
|
||||||
ctx->new_table->fts->dict_locked = true;
|
ctx->new_table->fts->dict_locked = true;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user