summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThirunarayanan Balathandayuthapani <thiru@mariadb.com>2021-04-06 18:51:41 +0530
committerThirunarayanan Balathandayuthapani <thiru@mariadb.com>2021-04-06 18:52:22 +0530
commitc32edd75155129fbfe353aed6402374d40e63b65 (patch)
treed6d4813fd4d6fbfbc350a5f268a2a8a530cfc656
parent6fe624b5acf51383d39eb0e547a03779d41cf4a8 (diff)
downloadmariadb-git-c32edd75155129fbfe353aed6402374d40e63b65.tar.gz
MDEV-25295 Aborted FTS_DOC_ID_INDEX considered as existing FTS_DOC_ID_INDEX during DDLbb-10.2-MDEV-25295
InnoDB should skip the dropped aborted FTS_DOC_ID_INDEX while checking the existing FTS_DOC_ID_INDEX in the table. InnoDB should able to create new FTS_DOC_ID_INDEX if the fulltext index is being added for the first time.
-rw-r--r--mysql-test/suite/innodb_fts/r/fulltext.result13
-rw-r--r--mysql-test/suite/innodb_fts/t/fulltext.test14
-rw-r--r--storage/innobase/handler/handler0alter.cc6
3 files changed, 31 insertions, 2 deletions
diff --git a/mysql-test/suite/innodb_fts/r/fulltext.result b/mysql-test/suite/innodb_fts/r/fulltext.result
index 42e294b3293..90deb48a223 100644
--- a/mysql-test/suite/innodb_fts/r/fulltext.result
+++ b/mysql-test/suite/innodb_fts/r/fulltext.result
@@ -691,3 +691,16 @@ FTS_DOC_ID t
2 foo bar
3 foo
DROP TABLE t;
+#
+# MDEV-25295 Aborted FTS_DOC_ID_INDEX considered as
+# existing FTS_DOC_ID_INDEX during DDL
+#
+SET sql_mode='';
+CREATE TABLE t1 (FTS_DOC_ID BIGINT UNSIGNED NOT NULL,title CHAR(1),body TEXT)engine=innodb;
+INSERT INTO t1 (FTS_DOC_ID,title,body)VALUES(1,0,0), (1,0,0);
+CREATE FULLTEXT INDEX idx1 ON t1 (title,body);
+ERROR 23000: Duplicate entry '' for key '*UNKNOWN*'
+CREATE FULLTEXT INDEX idx1 ON t1 (title,body);
+ERROR 23000: Duplicate entry '' for key '*UNKNOWN*'
+DROP TABLE t1;
+SET sql_mode = DEFAULT;
diff --git a/mysql-test/suite/innodb_fts/t/fulltext.test b/mysql-test/suite/innodb_fts/t/fulltext.test
index 663b202265b..1533c573ebf 100644
--- a/mysql-test/suite/innodb_fts/t/fulltext.test
+++ b/mysql-test/suite/innodb_fts/t/fulltext.test
@@ -717,3 +717,17 @@ while ($N)
}
DROP TABLE t;
+
+--echo #
+--echo # MDEV-25295 Aborted FTS_DOC_ID_INDEX considered as
+--echo # existing FTS_DOC_ID_INDEX during DDL
+--echo #
+SET sql_mode='';
+CREATE TABLE t1 (FTS_DOC_ID BIGINT UNSIGNED NOT NULL,title CHAR(1),body TEXT)engine=innodb;
+INSERT INTO t1 (FTS_DOC_ID,title,body)VALUES(1,0,0), (1,0,0);
+--error ER_DUP_ENTRY
+CREATE FULLTEXT INDEX idx1 ON t1 (title,body);
+--error ER_DUP_ENTRY
+CREATE FULLTEXT INDEX idx1 ON t1 (title,body);
+DROP TABLE t1;
+SET sql_mode = DEFAULT;
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index e03621795ba..ccc3fe3b921 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -2404,9 +2404,11 @@ innobase_fts_check_doc_id_index(
for (index = dict_table_get_first_index(table);
index; index = dict_table_get_next_index(index)) {
+
/* Check if there exists a unique index with the name of
- FTS_DOC_ID_INDEX_NAME */
- if (innobase_strcasecmp(index->name, FTS_DOC_ID_INDEX_NAME)) {
+ FTS_DOC_ID_INDEX_NAME and ignore the corrupted index */
+ if (index->type & DICT_CORRUPT
+ || innobase_strcasecmp(index->name, FTS_DOC_ID_INDEX_NAME)) {
continue;
}