diff options
-rw-r--r-- | mysql-test/suite/innodb_fts/r/innodb-fts-ddl.result | 32 | ||||
-rw-r--r-- | mysql-test/suite/innodb_fts/t/innodb-fts-ddl.test | 41 | ||||
-rw-r--r-- | storage/innobase/handler/handler0alter.cc | 17 |
3 files changed, 90 insertions, 0 deletions
diff --git a/mysql-test/suite/innodb_fts/r/innodb-fts-ddl.result b/mysql-test/suite/innodb_fts/r/innodb-fts-ddl.result index f23813aed48..f1e625037f3 100644 --- a/mysql-test/suite/innodb_fts/r/innodb-fts-ddl.result +++ b/mysql-test/suite/innodb_fts/r/innodb-fts-ddl.result @@ -234,3 +234,35 @@ CREATE TABLE t1 (FTS_DOC_ID BIGINT UNSIGNED PRIMARY KEY, f1 VARCHAR(200),FULLTEXT fidx(f1))engine=innodb; ALTER TABLE t1 DROP index fidx, ADD FULLTEXT INDEX(f1); DROP TABLE t1; +# +# MDEV-21478 Inplace alter fails to report error when +# FTS_DOC_ID is added +SET NAMES utf8; +CREATE TABLE t1(f1 INT NOT NULL)ENGINE=InnoDB; +ALTER TABLE t1 ADD FTS_DOC_ıD BIGINT UNSIGNED NOT NULL, ALGORITHM=COPY; +ALTER TABLE t1 DROP COLUMN FTS_DOC_ıD; +ALTER TABLE t1 ADD FTS_DOC_ıD BIGINT UNSIGNED NOT NULL, ALGORITHM=INPLACE; +DROP TABLE t1; +CREATE TABLE t1 (f1 INT NOT NULL)ENGINE=InnoDB; +ALTER TABLE t1 ADD FTS_DOC_İD BIGINT UNSIGNED NOT NULL, ALGORITHM=INPLACE; +ERROR 42000: Incorrect column name 'FTS_DOC_İD' +ALTER TABLE t1 ADD FTS_DOC_İD BIGINT UNSIGNED NOT NULL, ALGORITHM=COPY; +ERROR 42000: Incorrect column name 'FTS_DOC_İD' +ALTER TABLE t1 ADD fts_doc_id INT, ALGORITHM=COPY; +ERROR 42000: Incorrect column name 'fts_doc_id' +ALTER TABLE t1 ADD fts_doc_id INT, ALGORITHM=INPLACE; +ERROR 42000: Incorrect column name 'fts_doc_id' +ALTER TABLE t1 ADD fts_doc_id BIGINT UNSIGNED NOT NULL, ALGORITHM=COPY; +ERROR 42000: Incorrect column name 'fts_doc_id' +ALTER TABLE t1 ADD fts_doc_id BIGINT UNSIGNED NOT NULL, ALGORITHM=INPLACE; +ERROR 42000: Incorrect column name 'fts_doc_id' +ALTER TABLE t1 ADD FTS_DOC_ID INT UNSIGNED NOT NULL, ALGORITHM=COPY; +ERROR 42000: Incorrect column name 'FTS_DOC_ID' +ALTER TABLE t1 ADD FTS_DOC_ID INT UNSIGNED NOT NULL, ALGORITHM=INPLACE; +ERROR 42000: Incorrect column name 'FTS_DOC_ID' +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `f1` int(11) NOT NULL +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +DROP TABLE t1; diff --git a/mysql-test/suite/innodb_fts/t/innodb-fts-ddl.test b/mysql-test/suite/innodb_fts/t/innodb-fts-ddl.test index cd292803fb3..e055acc4968 100644 --- a/mysql-test/suite/innodb_fts/t/innodb-fts-ddl.test +++ b/mysql-test/suite/innodb_fts/t/innodb-fts-ddl.test @@ -278,3 +278,44 @@ CREATE TABLE t1 (FTS_DOC_ID BIGINT UNSIGNED PRIMARY KEY, f1 VARCHAR(200),FULLTEXT fidx(f1))engine=innodb; ALTER TABLE t1 DROP index fidx, ADD FULLTEXT INDEX(f1); DROP TABLE t1; + +--echo # +--echo # MDEV-21478 Inplace alter fails to report error when +--echo # FTS_DOC_ID is added + +SET NAMES utf8; + +CREATE TABLE t1(f1 INT NOT NULL)ENGINE=InnoDB; +ALTER TABLE t1 ADD FTS_DOC_ıD BIGINT UNSIGNED NOT NULL, ALGORITHM=COPY; +ALTER TABLE t1 DROP COLUMN FTS_DOC_ıD; +ALTER TABLE t1 ADD FTS_DOC_ıD BIGINT UNSIGNED NOT NULL, ALGORITHM=INPLACE; +DROP TABLE t1; + +CREATE TABLE t1 (f1 INT NOT NULL)ENGINE=InnoDB; + +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1 ADD FTS_DOC_İD BIGINT UNSIGNED NOT NULL, ALGORITHM=INPLACE; + +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1 ADD FTS_DOC_İD BIGINT UNSIGNED NOT NULL, ALGORITHM=COPY; + +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1 ADD fts_doc_id INT, ALGORITHM=COPY; + +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1 ADD fts_doc_id INT, ALGORITHM=INPLACE; + +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1 ADD fts_doc_id BIGINT UNSIGNED NOT NULL, ALGORITHM=COPY; + +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1 ADD fts_doc_id BIGINT UNSIGNED NOT NULL, ALGORITHM=INPLACE; + +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1 ADD FTS_DOC_ID INT UNSIGNED NOT NULL, ALGORITHM=COPY; + +--error ER_WRONG_COLUMN_NAME +ALTER TABLE t1 ADD FTS_DOC_ID INT UNSIGNED NOT NULL, ALGORITHM=INPLACE; + +SHOW CREATE TABLE t1; +DROP TABLE t1; diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 0bd11d74b09..7655b93e736 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -4663,6 +4663,23 @@ prepare_inplace_alter_table_dict( goto new_clustered_failed; } + /** Note the FTS_DOC_ID name is case sensitive due + to internal query parser. + FTS_DOC_ID column must be of BIGINT NOT NULL type + and it should be in all capitalized characters */ + if (!innobase_strcasecmp(field->field_name, + FTS_DOC_ID_COL_NAME)) { + if (col_type != DATA_INT + || field->real_maybe_null() + || col_len != sizeof(doc_id_t) + || strcmp(field->field_name, + FTS_DOC_ID_COL_NAME)) { + my_error(ER_WRONG_COLUMN_NAME, MYF(0), + field->field_name); + goto new_clustered_failed; + } + } + if (is_virtual) { dict_mem_table_add_v_col( ctx->new_table, ctx->heap, |