[Commits] 13c1b6faf23: MDEV-17778: Alter table leads to a truncation warning with ANALYZE command
revision-id: 13c1b6faf23ecf645b4e47868feb24ac22921bf4 (mariadb-10.3.10-82-g13c1b6faf23) parent(s): efc235d84d0df8a9895a5ae71c829303bbd39c8f author: Varun Gupta committer: Varun Gupta timestamp: 2018-11-20 17:36:37 +0530 message: MDEV-17778: Alter table leads to a truncation warning with ANALYZE command Alter statement changed the THD structure by setting the value to FIELD_CHECK_WARN and then not resetting it back. This led ANALYZE to throw a warning which previously it didn't. --- mysql-test/main/alter_table.result | 21 +++++++++++++++++++++ mysql-test/main/alter_table.test | 19 +++++++++++++++++++ sql/sql_table.cc | 12 +++++++----- 3 files changed, 47 insertions(+), 5 deletions(-) diff --git a/mysql-test/main/alter_table.result b/mysql-test/main/alter_table.result index 49c42479516..8e54e882979 100644 --- a/mysql-test/main/alter_table.result +++ b/mysql-test/main/alter_table.result @@ -2469,3 +2469,24 @@ DROP TABLE t1; # # End of 10.2 tests # +# +# MDEV-17778: Alter table leads to a truncation warning with ANALYZE command +# +set @save_use_stat_tables= @@use_stat_tables; +set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity; +set @@optimizer_use_condition_selectivity=4; +set @@use_stat_tables=PREFERABLY; +create table t1 (a int)engine=InnoDB; +insert into t1 values (1),(1),(2),(3); +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +alter table t1 change a b int; +analyze table t1; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +set @@use_stat_tables= @save_use_stat_tables; +set @@optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity; +drop table t1; diff --git a/mysql-test/main/alter_table.test b/mysql-test/main/alter_table.test index dfa8e2e148b..829f4013cb3 100644 --- a/mysql-test/main/alter_table.test +++ b/mysql-test/main/alter_table.test @@ -2021,3 +2021,22 @@ DROP TABLE t1; --echo # --echo # End of 10.2 tests --echo # + +--echo # +--echo # MDEV-17778: Alter table leads to a truncation warning with ANALYZE command +--echo # + +set @save_use_stat_tables= @@use_stat_tables; +set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity; +set @@optimizer_use_condition_selectivity=4; +set @@use_stat_tables=PREFERABLY; + +create table t1 (a int)engine=InnoDB; +insert into t1 values (1),(1),(2),(3); + +analyze table t1; +alter table t1 change a b int; +analyze table t1; +set @@use_stat_tables= @save_use_stat_tables; +set @@optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity; +drop table t1; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index b9fc431feb1..ba91b208d03 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -7401,11 +7401,6 @@ static bool mysql_inplace_alter_table(THD *thd, bool reopen_tables= false; bool res; - /* - Set the truncated column values of thd as warning - for alter table. - */ - thd->count_cuted_fields = CHECK_FIELD_WARN; DBUG_ENTER("mysql_inplace_alter_table"); /* @@ -9694,9 +9689,16 @@ bool mysql_alter_table(THD *thd, const LEX_CSTRING *new_db, if (use_inplace) { table->s->frm_image= &frm; + enum_check_fields save_count_cuted_fields= thd->count_cuted_fields; + /* + Set the truncated column values of thd as warning + for alter table. + */ + thd->count_cuted_fields = CHECK_FIELD_WARN; int res= mysql_inplace_alter_table(thd, table_list, table, altered_table, &ha_alter_info, inplace_supported, &target_mdl_request, &alter_ctx); + thd->count_cuted_fields= save_count_cuted_fields; my_free(const_cast<uchar*>(frm.str)); if (res)
participants (1)
-
Varun