diff --git a/mysql-test/suite/innodb/r/innodb-index.result b/mysql-test/suite/innodb/r/innodb-index.result index 8d7dcb84486..734cc41a8ea 100644 --- a/mysql-test/suite/innodb/r/innodb-index.result +++ b/mysql-test/suite/innodb/r/innodb-index.result @@ -1892,3 +1892,19 @@ f1 SELECT * FROM t2; f1 DROP TABLE t1, t2; +# +# MDEV-18186 assertion failure on missing InnoDB index +# +CREATE TABLE t (a INT, INDEX i1 (a)) ENGINE=INNODB; +DROP TABLE t; +CREATE TABLE t (a INT) ENGINE=INNODB; +SHOW CREATE TABLE t; +Table Create Table +t CREATE TABLE `t` ( + `a` int(11) DEFAULT NULL, + KEY `i1` (`a`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 +Warnings: +Warning 1082 InnoDB: Table test/t contains 0 indexes inside InnoDB, which is different from the number of indexes 1 defined in the MariaDB +Warning 1082 InnoDB: Table test/t contains 0 indexes inside InnoDB, which is different from the number of indexes 1 defined in the MariaDB +DROP TABLE t; diff --git a/mysql-test/suite/innodb/t/innodb-index.test b/mysql-test/suite/innodb/t/innodb-index.test index f199da54031..53f87cb78d5 100644 --- a/mysql-test/suite/innodb/t/innodb-index.test +++ b/mysql-test/suite/innodb/t/innodb-index.test @@ -1151,6 +1151,28 @@ SELECT * FROM t2; DROP TABLE t1, t2; +--echo # +--echo # MDEV-18186 assertion failure on missing InnoDB index +--echo # + +--disable_query_log +call mtr.add_suppression("Cannot find index i1 in InnoDB index dictionary"); +call mtr.add_suppression("InnoDB indexes are inconsistent with what defined"); +call mtr.add_suppression("Table test/t contains 0 indexes"); +call mtr.add_suppression("InnoDB could not find key no"); +--enable_query_log + +# Test an attempt to rename a nonexistent index inside InnoDB +-- let $MYSQL_DATA_DIR = `SELECT @@datadir` +CREATE TABLE t (a INT, INDEX i1 (a)) ENGINE=INNODB; +-- copy_file $MYSQL_DATA_DIR/test/t.frm $MYSQL_DATA_DIR/test/t.fr_ +DROP TABLE t; +CREATE TABLE t (a INT) ENGINE=INNODB; +-- remove_file $MYSQL_DATA_DIR/test/t.frm +-- move_file $MYSQL_DATA_DIR/test/t.fr_ $MYSQL_DATA_DIR/test/t.frm +SHOW CREATE TABLE t; +DROP TABLE t; + --disable_query_log call mtr.add_suppression("InnoDB: Tablespace .* was not found at .*t[12].ibd."); diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 611387d749b..195712a5e54 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -9534,7 +9534,6 @@ ha_innobase::innobase_get_index( if (keynr != MAX_KEY && table->s->keys > 0) { key = &table->key_info[keynr]; index = dict_table_get_index_on_name(ib_table, key->name); - ut_ad(index); } else { index = dict_table_get_first_index(ib_table); }