diff options
author | Sergei Golubchik <serg@mariadb.org> | 2018-12-16 18:32:05 +0100 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2018-12-20 08:06:55 +0100 |
commit | 2027841d5bc7e22ebb24a5a7538d0fd057dd8352 (patch) | |
tree | e235abdcbc3390142f8326a337942b7057808c38 | |
parent | d13302ff6013acee9ac5fb6946d0c91e2f303224 (diff) | |
download | mariadb-git-2027841d5bc7e22ebb24a5a7538d0fd057dd8352.tar.gz |
MDEV-16110 ALTER with ALGORITHM=INPLACE breaks temporary table with virtual columns
Part two, temporary tables.
Make temporary tables respect TABLE::m_needs_reopen.
See also 77cd754229b
-rw-r--r-- | mysql-test/r/alter_table_errors.result | 19 | ||||
-rw-r--r-- | mysql-test/t/alter_table_errors.test | 11 | ||||
-rw-r--r-- | sql/temporary_tables.cc | 7 |
3 files changed, 37 insertions, 0 deletions
diff --git a/mysql-test/r/alter_table_errors.result b/mysql-test/r/alter_table_errors.result index 020a30304d0..b26409e3d05 100644 --- a/mysql-test/r/alter_table_errors.result +++ b/mysql-test/r/alter_table_errors.result @@ -8,3 +8,22 @@ t CREATE TABLE `t` ( `v` int(11) GENERATED ALWAYS AS (`a`) VIRTUAL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 drop table t; +create temporary table t1 (a int, v int as (a)); +alter table t1 change column a b int, algorithm=inplace; +ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY +show create table t1; +Table Create Table +t1 CREATE TEMPORARY TABLE `t1` ( + `a` int(11) DEFAULT NULL, + `v` int(11) GENERATED ALWAYS AS (`a`) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +create temporary table t2 (a int, v int as (a)); +lock table t2 write; +alter table t2 change column a b int, algorithm=inplace; +ERROR 0A000: ALGORITHM=INPLACE is not supported for this operation. Try ALGORITHM=COPY +show create table t2; +Table Create Table +t2 CREATE TEMPORARY TABLE `t2` ( + `a` int(11) DEFAULT NULL, + `v` int(11) GENERATED ALWAYS AS (`a`) VIRTUAL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 diff --git a/mysql-test/t/alter_table_errors.test b/mysql-test/t/alter_table_errors.test index d9982ac26f4..8fa65b0f330 100644 --- a/mysql-test/t/alter_table_errors.test +++ b/mysql-test/t/alter_table_errors.test @@ -8,3 +8,14 @@ create table t (a int, v int as (a)) engine=innodb; alter table t change column a b tinyint, algorithm=inplace; show create table t; drop table t; + +create temporary table t1 (a int, v int as (a)); +--error ER_ALTER_OPERATION_NOT_SUPPORTED +alter table t1 change column a b int, algorithm=inplace; +show create table t1; + +create temporary table t2 (a int, v int as (a)); +lock table t2 write; +--error ER_ALTER_OPERATION_NOT_SUPPORTED +alter table t2 change column a b int, algorithm=inplace; +show create table t2; diff --git a/sql/temporary_tables.cc b/sql/temporary_tables.cc index a4ece127f96..29c9910f332 100644 --- a/sql/temporary_tables.cc +++ b/sql/temporary_tables.cc @@ -1042,6 +1042,13 @@ TABLE *THD::find_temporary_table(const char *key, uint key_length, case TMP_TABLE_ANY: found= true; break; } } + if (table && unlikely(table->m_needs_reopen)) + { + share->all_tmp_tables.remove(table); + free_temporary_table(table); + it.rewind(); + continue; + } result= table; break; } |