summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2019-01-29 14:07:59 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2019-01-29 15:20:26 +0200
commit5e06ee41a46dd9f336e73c0f9b6622c5ea5d548f (patch)
tree7ff9404880094b811dc2b76eb9c3b1e0330ec930
parentf877f6b49d97c02b307f83770c47c613c4bd669f (diff)
downloadmariadb-git-5e06ee41a46dd9f336e73c0f9b6622c5ea5d548f.tar.gz
MDEV-18222: Duplicated call to dict_foreign_remove_from_cache()
innobase_rename_column_try(): Declare fk_evict as std::set instead of std::list, in order to filter out duplicates.
-rw-r--r--mysql-test/suite/innodb/r/foreign_key.result12
-rw-r--r--mysql-test/suite/innodb/t/foreign_key.test13
-rw-r--r--storage/innobase/handler/handler0alter.cc8
-rw-r--r--storage/xtradb/handler/handler0alter.cc8
4 files changed, 33 insertions, 8 deletions
diff --git a/mysql-test/suite/innodb/r/foreign_key.result b/mysql-test/suite/innodb/r/foreign_key.result
index b6462000b46..f62a251161a 100644
--- a/mysql-test/suite/innodb/r/foreign_key.result
+++ b/mysql-test/suite/innodb/r/foreign_key.result
@@ -49,3 +49,15 @@ INSERT INTO t3 SET a=1;
kill query @id;
ERROR 70100: Query execution was interrupted
DROP TABLE t3,t1;
+#
+# MDEV-18222 InnoDB: Failing assertion: heap->magic_n == MEM_BLOCK_MAGIC_N
+# or ASAN heap-use-after-free in dict_foreign_remove_from_cache upon CHANGE COLUMN
+#
+CREATE TABLE t1 (a INT, UNIQUE(a), KEY(a)) ENGINE=InnoDB;
+ALTER TABLE t1 ADD FOREIGN KEY (a) REFERENCES t1 (a);
+SET SESSION FOREIGN_KEY_CHECKS = OFF;
+ALTER TABLE t1 CHANGE COLUMN a a TIME NOT NULL;
+ALTER TABLE t1 ADD pk INT NOT NULL AUTO_INCREMENT PRIMARY KEY;
+ALTER TABLE t1 CHANGE COLUMN a b TIME;
+SET SESSION FOREIGN_KEY_CHECKS = ON;
+DROP TABLE t1;
diff --git a/mysql-test/suite/innodb/t/foreign_key.test b/mysql-test/suite/innodb/t/foreign_key.test
index c1a92697dab..dc55a5c3a96 100644
--- a/mysql-test/suite/innodb/t/foreign_key.test
+++ b/mysql-test/suite/innodb/t/foreign_key.test
@@ -73,3 +73,16 @@ reap;
disconnect fk;
DROP TABLE t3,t1;
+
+--echo #
+--echo # MDEV-18222 InnoDB: Failing assertion: heap->magic_n == MEM_BLOCK_MAGIC_N
+--echo # or ASAN heap-use-after-free in dict_foreign_remove_from_cache upon CHANGE COLUMN
+--echo #
+CREATE TABLE t1 (a INT, UNIQUE(a), KEY(a)) ENGINE=InnoDB;
+ALTER TABLE t1 ADD FOREIGN KEY (a) REFERENCES t1 (a);
+SET SESSION FOREIGN_KEY_CHECKS = OFF;
+ALTER TABLE t1 CHANGE COLUMN a a TIME NOT NULL;
+ALTER TABLE t1 ADD pk INT NOT NULL AUTO_INCREMENT PRIMARY KEY;
+ALTER TABLE t1 CHANGE COLUMN a b TIME;
+SET SESSION FOREIGN_KEY_CHECKS = ON;
+DROP TABLE t1;
diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc
index 25019b8f964..d67defa56e8 100644
--- a/storage/innobase/handler/handler0alter.cc
+++ b/storage/innobase/handler/handler0alter.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2005, 2018, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, 2018, MariaDB Corporation.
+Copyright (c) 2017, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -4579,7 +4579,7 @@ err_exit:
rename_foreign:
trx->op_info = "renaming column in SYS_FOREIGN_COLS";
- std::list<dict_foreign_t*> fk_evict;
+ std::set<dict_foreign_t*> fk_evict;
bool foreign_modified;
for (dict_foreign_set::const_iterator it = user_table->foreign_set.begin();
@@ -4619,7 +4619,7 @@ rename_foreign:
}
if (foreign_modified) {
- fk_evict.push_back(foreign);
+ fk_evict.insert(foreign);
}
}
@@ -4661,7 +4661,7 @@ rename_foreign:
}
if (foreign_modified) {
- fk_evict.push_back(foreign);
+ fk_evict.insert(foreign);
}
}
diff --git a/storage/xtradb/handler/handler0alter.cc b/storage/xtradb/handler/handler0alter.cc
index e932e2cbbdb..b7705691949 100644
--- a/storage/xtradb/handler/handler0alter.cc
+++ b/storage/xtradb/handler/handler0alter.cc
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2005, 2018, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2017, 2018, MariaDB Corporation.
+Copyright (c) 2017, 2019, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -4593,7 +4593,7 @@ err_exit:
rename_foreign:
trx->op_info = "renaming column in SYS_FOREIGN_COLS";
- std::list<dict_foreign_t*> fk_evict;
+ std::set<dict_foreign_t*> fk_evict;
bool foreign_modified;
for (dict_foreign_set::const_iterator it = user_table->foreign_set.begin();
@@ -4633,7 +4633,7 @@ rename_foreign:
}
if (foreign_modified) {
- fk_evict.push_back(foreign);
+ fk_evict.insert(foreign);
}
}
@@ -4675,7 +4675,7 @@ rename_foreign:
}
if (foreign_modified) {
- fk_evict.push_back(foreign);
+ fk_evict.insert(foreign);
}
}