From 662217a592af4fef8a635bbd56544b5d56e5dcd6 Mon Sep 17 00:00:00 2001 From: Eugene Kosov Date: Wed, 9 Jan 2019 16:36:41 +0300 Subject: [PATCH] MDEV-18186 assertion failure on missing InnoDB index This was introduced in 1a7a018939e19a0037808489be0fd1680581aec3 MDEV-16557 Remove INNOBASE_SHARE::idx_trans_tbl ha_innobase::innobase_get_index: remove incorrect assertion. Index nullability is checked in subsequent ifs. Closes #1079 --- mysql-test/suite/innodb/r/innodb-index.result | 16 ++++++++++++++ mysql-test/suite/innodb/t/innodb-index.test | 22 +++++++++++++++++++ storage/innobase/handler/ha_innodb.cc | 1 - 3 files changed, 38 insertions(+), 1 deletion(-) 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); }