Commit 5e06ee41 authored by Marko Mäkelä's avatar Marko Mäkelä

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.
parent f877f6b4
...@@ -49,3 +49,15 @@ INSERT INTO t3 SET a=1; ...@@ -49,3 +49,15 @@ INSERT INTO t3 SET a=1;
kill query @id; kill query @id;
ERROR 70100: Query execution was interrupted ERROR 70100: Query execution was interrupted
DROP TABLE t3,t1; 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;
...@@ -73,3 +73,16 @@ reap; ...@@ -73,3 +73,16 @@ reap;
disconnect fk; disconnect fk;
DROP TABLE t3,t1; 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;
/***************************************************************************** /*****************************************************************************
Copyright (c) 2005, 2018, Oracle and/or its affiliates. All Rights Reserved. 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 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 the terms of the GNU General Public License as published by the Free Software
...@@ -4579,7 +4579,7 @@ innobase_rename_column_try( ...@@ -4579,7 +4579,7 @@ innobase_rename_column_try(
rename_foreign: rename_foreign:
trx->op_info = "renaming column in SYS_FOREIGN_COLS"; 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; bool foreign_modified;
for (dict_foreign_set::const_iterator it = user_table->foreign_set.begin(); for (dict_foreign_set::const_iterator it = user_table->foreign_set.begin();
...@@ -4619,7 +4619,7 @@ innobase_rename_column_try( ...@@ -4619,7 +4619,7 @@ innobase_rename_column_try(
} }
if (foreign_modified) { if (foreign_modified) {
fk_evict.push_back(foreign); fk_evict.insert(foreign);
} }
} }
...@@ -4661,7 +4661,7 @@ innobase_rename_column_try( ...@@ -4661,7 +4661,7 @@ innobase_rename_column_try(
} }
if (foreign_modified) { if (foreign_modified) {
fk_evict.push_back(foreign); fk_evict.insert(foreign);
} }
} }
......
/***************************************************************************** /*****************************************************************************
Copyright (c) 2005, 2018, Oracle and/or its affiliates. All Rights Reserved. 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 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 the terms of the GNU General Public License as published by the Free Software
...@@ -4593,7 +4593,7 @@ innobase_rename_column_try( ...@@ -4593,7 +4593,7 @@ innobase_rename_column_try(
rename_foreign: rename_foreign:
trx->op_info = "renaming column in SYS_FOREIGN_COLS"; 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; bool foreign_modified;
for (dict_foreign_set::const_iterator it = user_table->foreign_set.begin(); for (dict_foreign_set::const_iterator it = user_table->foreign_set.begin();
...@@ -4633,7 +4633,7 @@ innobase_rename_column_try( ...@@ -4633,7 +4633,7 @@ innobase_rename_column_try(
} }
if (foreign_modified) { if (foreign_modified) {
fk_evict.push_back(foreign); fk_evict.insert(foreign);
} }
} }
...@@ -4675,7 +4675,7 @@ innobase_rename_column_try( ...@@ -4675,7 +4675,7 @@ innobase_rename_column_try(
} }
if (foreign_modified) { if (foreign_modified) {
fk_evict.push_back(foreign); fk_evict.insert(foreign);
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment