From cca9547892d620e969c2933465bf736ed1a592c9 Mon Sep 17 00:00:00 2001 From: Monty Date: Mon, 16 Oct 2023 12:55:17 +0300 Subject: [PATCH] Post fix for MDEV-32449 --- mysql-test/main/alter_table.result | 6 ++++++ mysql-test/main/alter_table.test | 8 ++++++++ sql/sql_table.cc | 5 +++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/mysql-test/main/alter_table.result b/mysql-test/main/alter_table.result index 084b757530a..b8f85e33944 100644 --- a/mysql-test/main/alter_table.result +++ b/mysql-test/main/alter_table.result @@ -3118,6 +3118,12 @@ t2 CREATE TABLE `t2` ( KEY `altcol1` (`altcol1`(2300)) ) ENGINE=Aria DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci PAGE_CHECKSUM=1 ROW_FORMAT=PAGE drop table t1,t2; +# Another test for MDEV-32449 +CREATE TABLE t1 (a POINT, b POINT, KEY(a)) ENGINE=Aria; +ALTER TABLE t1 ADD FOREIGN KEY (a) REFERENCES t (b); +CREATE TEMPORARY TABLE t2 LIKE t1; +DROP TEMPORARY TABLE t2; +DROP TABLE t1; # # End of 10.6 tests # diff --git a/mysql-test/main/alter_table.test b/mysql-test/main/alter_table.test index c8ad4c23e5c..40f48ac87bd 100644 --- a/mysql-test/main/alter_table.test +++ b/mysql-test/main/alter_table.test @@ -2397,6 +2397,14 @@ show create table t1; show create table t2; drop table t1,t2; +--echo # Another test for MDEV-32449 + +CREATE TABLE t1 (a POINT, b POINT, KEY(a)) ENGINE=Aria; +ALTER TABLE t1 ADD FOREIGN KEY (a) REFERENCES t (b); +CREATE TEMPORARY TABLE t2 LIKE t1; +DROP TEMPORARY TABLE t2; +DROP TABLE t1; + --echo # --echo # End of 10.6 tests --echo # diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 1ae4d2c88f0..6f9e7bdab86 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2898,10 +2898,11 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, key_iterator.rewind(); while ((key=key_iterator++)) { - if (key->type == Key::IGNORE_KEY && !create_info->tmp_table()) + if (key->type == Key::IGNORE_KEY) { /* The key was replaced by another key */ - if (alter_info->add_stat_drop_index(thd, &key->name)) + if (!create_info->tmp_table() && + alter_info->add_stat_drop_index(thd, &key->name)) DBUG_RETURN(true); continue; }