summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mysql-test/suite/innodb/r/instant_alter_index_rename.result7
-rw-r--r--mysql-test/suite/innodb/t/instant_alter_index_rename.test10
-rw-r--r--sql/sql_table.cc8
3 files changed, 21 insertions, 4 deletions
diff --git a/mysql-test/suite/innodb/r/instant_alter_index_rename.result b/mysql-test/suite/innodb/r/instant_alter_index_rename.result
index 93bbf6ee193..52051eff0bd 100644
--- a/mysql-test/suite/innodb/r/instant_alter_index_rename.result
+++ b/mysql-test/suite/innodb/r/instant_alter_index_rename.result
@@ -176,3 +176,10 @@ check table rename_column_and_index;
Table Op Msg_type Msg_text
test.rename_column_and_index check status OK
drop table rename_column_and_index;
+#
+# MDEV-19189: ASAN memcpy-param-overlap in fill_alter_inplace_info upon adding indexes
+#
+CREATE TABLE t1 (f1 INT, f2 INT, f3 INT);
+ALTER TABLE t1 ADD FOREIGN KEY f (f2) REFERENCES xx(f2);
+ALTER TABLE t1 ADD FOREIGN KEY (f2) REFERENCES t1(f2), ADD KEY (f3), ADD KEY (f1);
+DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/t/instant_alter_index_rename.test b/mysql-test/suite/innodb/t/instant_alter_index_rename.test
index 3150503c815..3a608a00837 100644
--- a/mysql-test/suite/innodb/t/instant_alter_index_rename.test
+++ b/mysql-test/suite/innodb/t/instant_alter_index_rename.test
@@ -184,3 +184,13 @@ alter table rename_column_and_index
show create table rename_column_and_index;
check table rename_column_and_index;
drop table rename_column_and_index;
+
+
+--echo #
+--echo # MDEV-19189: ASAN memcpy-param-overlap in fill_alter_inplace_info upon adding indexes
+--echo #
+
+CREATE TABLE t1 (f1 INT, f2 INT, f3 INT);
+ALTER TABLE t1 ADD FOREIGN KEY f (f2) REFERENCES xx(f2);
+ALTER TABLE t1 ADD FOREIGN KEY (f2) REFERENCES t1(f2), ADD KEY (f3), ADD KEY (f1);
+DROP TABLE t1;
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 9e44eefbf9b..cf1be27ef3b 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -7123,10 +7123,10 @@ static bool fill_alter_inplace_info(THD *thd, TABLE *table, bool varchar,
--ha_alter_info->index_add_count;
--ha_alter_info->index_drop_count;
- memcpy(add_buffer + i, add_buffer + i + 1,
- sizeof(add_buffer[0]) * (ha_alter_info->index_add_count - i));
- memcpy(drop_buffer + j, drop_buffer + j + 1,
- sizeof(drop_buffer[0]) * (ha_alter_info->index_drop_count - j));
+ memmove(add_buffer + i, add_buffer + i + 1,
+ sizeof(add_buffer[0]) * (ha_alter_info->index_add_count - i));
+ memmove(drop_buffer + j, drop_buffer + j + 1,
+ sizeof(drop_buffer[0]) * (ha_alter_info->index_drop_count - j));
--i; // this index once again
break;
}