diff --git a/mysql-test/r/bug71179.result b/mysql-test/r/bug71179.result new file mode 100644 index 0000000..f1f56a6 --- /dev/null +++ b/mysql-test/r/bug71179.result @@ -0,0 +1,16 @@ +include/master-slave.inc +[connection master] +DROP TABLE IF EXISTS t1; +Warnings: +Note 1051 Unknown table 't1' +CREATE TABLE t1 AS SELECT REPEAT('A',1000) DIV 1 AS a; +Warnings: +Warning 1439 Display width out of range for column 't1' (max = 255) +Warning 1366 Incorrect decimal value: '' for column '' at row -1 +SHOW CREATE TABLE t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` bigint(255) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +drop table t1; +include/rpl_end.inc diff --git a/mysql-test/t/bug71179.test b/mysql-test/t/bug71179.test new file mode 100644 index 0000000..72bda34 --- /dev/null +++ b/mysql-test/t/bug71179.test @@ -0,0 +1,10 @@ +--source include/master-slave.inc +--source include/have_binlog_format_row.inc + +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 AS SELECT REPEAT('A',1000) DIV 1 AS a; +SHOW CREATE TABLE t1; + +drop table t1; +--sync_slave_with_master +--source include/rpl_end.inc diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 1bc91d9..60555ce 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -2850,6 +2850,19 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, which was set in the parser. This is necessary if we're executing a prepared statement for the second time. */ + if (sql_field->sql_type == MYSQL_TYPE_LONG || sql_field->sql_type == MYSQL_TYPE_LONGLONG) + { + if (sql_field->char_length > MAX_FIELD_CHARLENGTH) + { + sql_field->char_length= MAX_FIELD_CHARLENGTH; + + char warn_buff[MYSQL_ERRMSG_SIZE]; + my_snprintf(warn_buff, sizeof(warn_buff), ER(ER_TOO_BIG_DISPLAYWIDTH), + create_info->alias, MAX_FIELD_CHARLENGTH); + push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, + ER_TOO_BIG_DISPLAYWIDTH, warn_buff); + } + } sql_field->length= sql_field->char_length; save_cs= sql_field->charset= get_sql_field_charset(sql_field, create_info);