diff options
author | Varun Gupta <varun.gupta@mariadb.com> | 2018-12-10 00:34:41 +0530 |
---|---|---|
committer | Varun Gupta <varun.gupta@mariadb.com> | 2018-12-10 18:27:13 +0530 |
commit | 8aef7f2bb925b7496d0157165e33b12eef2812a3 (patch) | |
tree | 97164dea25b90b114b11872260072158a317e578 | |
parent | a72516348b2c5ebb2b6b79c013a79f90e697f2b7 (diff) | |
download | mariadb-git-8aef7f2bb925b7496d0157165e33b12eef2812a3.tar.gz |
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.
-rw-r--r-- | mysql-test/main/alter_table.result | 21 | ||||
-rw-r--r-- | mysql-test/main/alter_table.test | 19 | ||||
-rw-r--r-- | mysql-test/main/selectivity_innodb.result | 1 | ||||
-rw-r--r-- | mysql-test/main/statistics.result | 10 | ||||
-rw-r--r-- | mysql-test/suite/gcol/r/gcol_keys_innodb.result | 2 | ||||
-rw-r--r-- | sql/sql_table.cc | 12 |
6 files changed, 47 insertions, 18 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/mysql-test/main/selectivity_innodb.result b/mysql-test/main/selectivity_innodb.result index 921bd20fc69..93917065722 100644 --- a/mysql-test/main/selectivity_innodb.result +++ b/mysql-test/main/selectivity_innodb.result @@ -1150,7 +1150,6 @@ alter table t1 change column a a int; analyze table t1; Table Op Msg_type Msg_text test.t1 analyze status Engine-independent statistics collected -test.t1 analyze Note Data truncated for column 'avg_frequency' at row 1 test.t1 analyze status OK flush table t1; explain extended select * from t1 where a between 5 and 7; diff --git a/mysql-test/main/statistics.result b/mysql-test/main/statistics.result index 574eb5f4727..34a17cf049c 100644 --- a/mysql-test/main/statistics.result +++ b/mysql-test/main/statistics.result @@ -1086,9 +1086,6 @@ test t2 idx4 3 1.1304 ANALYZE TABLE t2 PERSISTENT FOR COLUMNS() INDEXES ALL; Table Op Msg_type Msg_text test.t2 analyze status Engine-independent statistics collected -test.t2 analyze Note Data truncated for column 'avg_frequency' at row 1 -test.t2 analyze Note Data truncated for column 'avg_frequency' at row 1 -test.t2 analyze Note Data truncated for column 'avg_frequency' at row 1 test.t2 analyze status OK SELECT * FROM mysql.index_stats ORDER BY index_name, prefix_arity, table_name; db_name table_name index_name prefix_arity avg_frequency @@ -1149,11 +1146,6 @@ test t2 idx4 4 1.0000 ANALYZE TABLE t2 PERSISTENT FOR COLUMNS ALL INDEXES ALL; Table Op Msg_type Msg_text test.t2 analyze status Engine-independent statistics collected -test.t2 analyze Note Data truncated for column 'avg_length' at row 1 -test.t2 analyze Note Data truncated for column 'avg_frequency' at row 1 -test.t2 analyze Note Data truncated for column 'avg_frequency' at row 1 -test.t2 analyze Note Data truncated for column 'avg_frequency' at row 1 -test.t2 analyze Note Data truncated for column 'avg_frequency' at row 1 test.t2 analyze status OK SELECT * FROM mysql.index_stats ORDER BY index_name, prefix_arity, table_name; db_name table_name index_name prefix_arity avg_frequency @@ -1179,8 +1171,6 @@ test t2 idx3 1 8.5000 ANALYZE TABLE t2 PERSISTENT FOR COLUMNS() INDEXES ALL; Table Op Msg_type Msg_text test.t2 analyze status Engine-independent statistics collected -test.t2 analyze Note Data truncated for column 'avg_frequency' at row 1 -test.t2 analyze Note Data truncated for column 'avg_frequency' at row 1 test.t2 analyze status OK SELECT * FROM mysql.index_stats ORDER BY index_name, prefix_arity, table_name; db_name table_name index_name prefix_arity avg_frequency diff --git a/mysql-test/suite/gcol/r/gcol_keys_innodb.result b/mysql-test/suite/gcol/r/gcol_keys_innodb.result index 577b3255620..de88b745292 100644 --- a/mysql-test/suite/gcol/r/gcol_keys_innodb.result +++ b/mysql-test/suite/gcol/r/gcol_keys_innodb.result @@ -696,8 +696,6 @@ Warning 1264 Out of range value for column 'b' at row 1 SELECT * FROM t WHERE c = '0'; a b c 1 127 0 -Warnings: -Warning 1264 Out of range value for column 'b' at row 1 DROP TABLE t; # # Bug#21688115 VIRTUAL COLUMN COMPUTATION SAVE_IN_FIELD() 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) |