diff options
author | Sergei Golubchik <serg@mariadb.org> | 2022-06-29 16:57:22 +0200 |
---|---|---|
committer | Nikita Malyavin <nikitamalyavin@gmail.com> | 2022-10-17 15:24:45 +0300 |
commit | 044980211477d9ba2f4b4eac7ed8f5899ec6033a (patch) | |
tree | ad4f817bc5dd121f512bfd9d380e14549afc39ad | |
parent | dcd45400ec0e330b69b6ff7613f596876f435a96 (diff) | |
download | mariadb-git-044980211477d9ba2f4b4eac7ed8f5899ec6033a.tar.gz |
MDEV-28771 Assertion `table->in_use&&tdc->flushed' failed after ALTER
don't simply set tdc->flushed, use flush_unused(1) that removes opened
but unused TABLE instances (that would otherwise prevent TABLE_SHARE from
being closed by keeping the ref_count>0).
-rw-r--r-- | mysql-test/main/alter_table_online.result | 56 | ||||
-rw-r--r-- | mysql-test/main/alter_table_online.test | 35 | ||||
-rw-r--r-- | sql/sql_table.cc | 2 |
3 files changed, 92 insertions, 1 deletions
diff --git a/mysql-test/main/alter_table_online.result b/mysql-test/main/alter_table_online.result new file mode 100644 index 00000000000..5015b4cb5b7 --- /dev/null +++ b/mysql-test/main/alter_table_online.result @@ -0,0 +1,56 @@ +# +# MDEV-28771 Assertion `table->in_use&&tdc->flushed' failed after ALTER +# +create table t (a char(1)); +insert into t values ('a'),('b'); +select * from t join t as t2 join t as t3; +a a a +a a a +b a a +a b a +b b a +a a b +b a b +a b b +b b b +alter table t modify a int; +ERROR 22007: Truncated incorrect INTEGER value: 'a' +select * from t; +a +a +b +drop table t; +create table t (c double precision key,c2 char,c3 year); +insert into t values (7,3,1); +select a from t where a=all (select a from t where b=2 union select a from t where b=2); +ERROR 42S22: Unknown column 'a' in 'field list' +insert into t values (3,1,1); +alter table t change c c date,add key(c); +ERROR 22007: Incorrect date value: '7' for column `test`.`t`.`c` at row 1 +select * from t; +c c2 c3 +7 3 2001 +3 1 2001 +drop table t; +set sql_mode=''; +create table t (c char unique,c2 int,stamp timestamp); +insert into t values (1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5); +Warnings: +Warning 1265 Data truncated for column 'stamp' at row 1 +Warning 1265 Data truncated for column 'stamp' at row 2 +Warning 1265 Data truncated for column 'stamp' at row 3 +Warning 1265 Data truncated for column 'stamp' at row 4 +Warning 1265 Data truncated for column 'stamp' at row 5 +update t set c=(select * from t) where c in (select * from t); +ERROR 21000: Operand should contain 1 column(s) +alter table t modify c date; +ERROR 23000: Duplicate entry '0000-00-00' for key 'c' +select * from t; +c c2 stamp +1 1 0000-00-00 00:00:00 +2 2 0000-00-00 00:00:00 +3 3 0000-00-00 00:00:00 +4 4 0000-00-00 00:00:00 +5 5 0000-00-00 00:00:00 +drop table t; +set sql_mode=default; diff --git a/mysql-test/main/alter_table_online.test b/mysql-test/main/alter_table_online.test new file mode 100644 index 00000000000..a9e20fa05f6 --- /dev/null +++ b/mysql-test/main/alter_table_online.test @@ -0,0 +1,35 @@ +--source include/binlog_combinations.inc +--source include/have_innodb.inc + +--echo # +--echo # MDEV-28771 Assertion `table->in_use&&tdc->flushed' failed after ALTER +--echo # + +create table t (a char(1)); +insert into t values ('a'),('b'); +select * from t join t as t2 join t as t3; +--error ER_TRUNCATED_WRONG_VALUE +alter table t modify a int; +select * from t; +drop table t; + +create table t (c double precision key,c2 char,c3 year); +insert into t values (7,3,1); +--error ER_BAD_FIELD_ERROR +select a from t where a=all (select a from t where b=2 union select a from t where b=2); +insert into t values (3,1,1); +--error ER_TRUNCATED_WRONG_VALUE +alter table t change c c date,add key(c); +select * from t; +drop table t; + +set sql_mode=''; +create table t (c char unique,c2 int,stamp timestamp); +insert into t values (1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,5,5); +--error ER_OPERAND_COLUMNS +update t set c=(select * from t) where c in (select * from t); +--error ER_DUP_ENTRY +alter table t modify c date; +select * from t; +drop table t; +set sql_mode=default; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 17da14bb6af..7dffbd57134 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -12407,7 +12407,7 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to, } else if (online) // error was on copy stage { - from->s->tdc->flushed= 1; // to free the binlog + from->s->tdc->flush_unused(1); // to free the binlog } #endif |