Skip to content
Permalink
Browse files
MDEV-28912 NON-UNIQUE FTS_DOC_ID index mistaken as FTS_DOC_ID_INDEX
- InnoDB mistakenly identifies the non-unique FTS_DOC_ID index as
FTS_DOC_ID_INDEX while loading the table. dict_load_indexes()
should check whether the index is unique before assigning
fts_doc_id_index
  • Loading branch information
Thirunarayanan authored and dr-m committed Jul 1, 2022
1 parent 7c35ad1 commit 990cde8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
@@ -271,3 +271,10 @@ fts_doc_id first_name last_name score
6 Ned Flanders 0
7 Nelson Muntz 0
DROP TABLE t1;
CREATE TABLE t1(a INT, b TEXT, FTS_DOC_ID BIGINT UNSIGNED NOT NULL,
KEY FTS_DOC_ID_INDEX(FTS_DOC_ID))ENGINE=InnoDB;
ALTER TABLE t1 ADD COLUMN c INT as (a) VIRTUAL;
ALTER TABLE t1 ADD d INT NULL;
ALTER TABLE t1 ADD FULLTEXT(b);
ERROR HY000: Index 'FTS_DOC_ID_INDEX' is of wrong type for an InnoDB FULLTEXT index
DROP TABLE t1;
@@ -257,3 +257,14 @@ INSERT INTO t1 (id, first_name, last_name) VALUES
analyze table t1;
SELECT fts_doc_id, first_name, last_name, MATCH(first_name) AGAINST('Homer' IN BOOLEAN MODE) AS score FROM t1;
DROP TABLE t1;

#
# MDEV-28912 NON-UNIQUE FTS_DOC_ID mistaken as FTS_DOC_ID_INDEX
#
CREATE TABLE t1(a INT, b TEXT, FTS_DOC_ID BIGINT UNSIGNED NOT NULL,
KEY FTS_DOC_ID_INDEX(FTS_DOC_ID))ENGINE=InnoDB;
ALTER TABLE t1 ADD COLUMN c INT as (a) VIRTUAL;
ALTER TABLE t1 ADD d INT NULL;
--error ER_INNODB_FT_WRONG_DOCID_INDEX
ALTER TABLE t1 ADD FULLTEXT(b);
DROP TABLE t1;
@@ -2590,8 +2590,11 @@ dict_load_indexes(
ut_ad(table->fts_doc_id_index == NULL);

if (table->fts != NULL) {
table->fts_doc_id_index = dict_table_get_index_on_name(
dict_index_t *idx = dict_table_get_index_on_name(
table, FTS_DOC_ID_INDEX_NAME);
if (idx && dict_index_is_unique(idx)) {
table->fts_doc_id_index = idx;
}
}

/* If the table contains FTS indexes, populate table->fts->indexes */

0 comments on commit 990cde8

Please sign in to comment.