diff options
author | Aleksey Midenkov <midenok@gmail.com> | 2020-06-15 19:10:39 +0300 |
---|---|---|
committer | Aleksey Midenkov <midenok@gmail.com> | 2020-06-15 19:10:39 +0300 |
commit | 30d41c8102c36af7551b3ae77e48efbeb6d7ecea (patch) | |
tree | 699c0af1519ea98f9ba1f08b9c4a6d8ce08e0b6e | |
parent | 359d5f56c315cbc428e96d5d2d83d5a7ba077d06 (diff) | |
download | mariadb-git-30d41c8102c36af7551b3ae77e48efbeb6d7ecea.tar.gz |
MDEV-22881 Unexpected errors, corrupt output, Valgrind / ASAN errors in Item_ident::print or append_identifier
After this code
end_inplace:
if (thd->locked_tables_list.reopen_tables(thd, false))
goto err_with_mdl_after_alter;
table is not reopened (need_reopen is false) but
some_table_marked_for_reopen is reset to false.
Item_field is allocated on table lock and assigned new name on first
ALTER which is then freed at the end of the command. Second ALTER
accessess this Item_field and gets garbage value.
-rw-r--r-- | mysql-test/main/alter_table.result | 11 | ||||
-rw-r--r-- | mysql-test/main/alter_table.test | 12 | ||||
-rw-r--r-- | sql/sql_base.cc | 3 |
3 files changed, 25 insertions, 1 deletions
diff --git a/mysql-test/main/alter_table.result b/mysql-test/main/alter_table.result index 3a2f72b0988..197e52b35ca 100644 --- a/mysql-test/main/alter_table.result +++ b/mysql-test/main/alter_table.result @@ -3311,5 +3311,16 @@ t2 CREATE TABLE `t2` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 drop table t2; # +# MDEV-22881 Unexpected errors, corrupt output, Valgrind / ASAN errors in Item_ident::print or append_identifier +# +create table t1 (a int check (a >= 0)); +lock tables t1 write; +alter table t1 rename column a to a; +alter table t1 rename key if exists x to xx; +Warnings: +Note 1176 Key 'x' doesn't exist in table 't1' +unlock tables; +drop table t1; +# # End of 10.5 tests # diff --git a/mysql-test/main/alter_table.test b/mysql-test/main/alter_table.test index 2cf3639ae59..6fe61a3222a 100644 --- a/mysql-test/main/alter_table.test +++ b/mysql-test/main/alter_table.test @@ -2518,5 +2518,17 @@ show create table t2; drop table t2; --echo # +--echo # MDEV-22881 Unexpected errors, corrupt output, Valgrind / ASAN errors in Item_ident::print or append_identifier +--echo # +create table t1 (a int check (a >= 0)); +lock tables t1 write; +alter table t1 rename column a to a; +alter table t1 rename key if exists x to xx; + +# cleanup +unlock tables; +drop table t1; + +--echo # --echo # End of 10.5 tests --echo # diff --git a/sql/sql_base.cc b/sql/sql_base.cc index d7be718b1ca..88a28c470c0 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -2592,7 +2592,8 @@ Locked_tables_list::reopen_tables(THD *thd, bool need_reopen) /* Reset flag that some table was marked for reopen */ - some_table_marked_for_reopen= 0; + if (need_reopen) + some_table_marked_for_reopen= 0; for (TABLE_LIST *table_list= m_locked_tables; table_list; table_list= table_list->next_global) |