Commit 268a68ad authored by jimw@mysql.com's avatar jimw@mysql.com

Fix error message when creating a non-string field with a display

width beyond the maximum. (Bug #6080)
parent 9959482c
...@@ -23,3 +23,8 @@ ERROR 42S22: Unknown column 't1.b' in 'order clause' ...@@ -23,3 +23,8 @@ ERROR 42S22: Unknown column 't1.b' in 'order clause'
select count(*),b from t1; select count(*),b from t1;
ERROR 42S22: Unknown column 'b' in 'field list' ERROR 42S22: Unknown column 'b' in 'field list'
drop table t1; drop table t1;
create table t1 (a int(256));
ERROR 42000: Display width out of range for column 'a' (max = 255)
set sql_mode='traditional';
create table t1 (a varchar(66000));
ERROR 42000: Column length too big for column 'a' (max = 65535); use BLOB or TEXT instead
...@@ -36,7 +36,7 @@ select 0 + b'1000000000000001'; ...@@ -36,7 +36,7 @@ select 0 + b'1000000000000001';
32769 32769
drop table if exists t1; drop table if exists t1;
create table t1 (a bit(65)); create table t1 (a bit(65));
ERROR 42000: Column length too big for column 'a' (max = 64); use BLOB or TEXT instead ERROR 42000: Display width out of range for column 'a' (max = 64)
create table t1 (a bit(0)); create table t1 (a bit(0));
show create table t1; show create table t1;
Table Create Table Table Create Table
......
...@@ -36,7 +36,7 @@ select 0 + b'1000000000000001'; ...@@ -36,7 +36,7 @@ select 0 + b'1000000000000001';
32769 32769
drop table if exists t1; drop table if exists t1;
create table t1 (a bit(65)) engine=innodb; create table t1 (a bit(65)) engine=innodb;
ERROR 42000: Column length too big for column 'a' (max = 64); use BLOB or TEXT instead ERROR 42000: Display width out of range for column 'a' (max = 64)
create table t1 (a bit(0)) engine=innodb; create table t1 (a bit(0)) engine=innodb;
show create table t1; show create table t1;
Table Create Table Table Create Table
......
...@@ -31,3 +31,14 @@ select count(*),b from t1; ...@@ -31,3 +31,14 @@ select count(*),b from t1;
drop table t1; drop table t1;
# End of 4.1 tests # End of 4.1 tests
#
# Bug #6080: Error message for a field with a display width that is too long
#
--error 1438
create table t1 (a int(256));
set sql_mode='traditional';
--error 1074
create table t1 (a varchar(66000));
# End of 5.0 tests
...@@ -20,7 +20,7 @@ select 0 + b'1000000000000001'; ...@@ -20,7 +20,7 @@ select 0 + b'1000000000000001';
drop table if exists t1; drop table if exists t1;
--enable_warnings --enable_warnings
--error 1074 --error 1438
create table t1 (a bit(65)) engine=innodb; create table t1 (a bit(65)) engine=innodb;
create table t1 (a bit(0)) engine=innodb; create table t1 (a bit(0)) engine=innodb;
......
...@@ -5388,3 +5388,5 @@ ER_STACK_OVERRUN_NEED_MORE ...@@ -5388,3 +5388,5 @@ ER_STACK_OVERRUN_NEED_MORE
eng "Thread stack overrun: %ld bytes used of a %ld byte stack, and %ld bytes needed. Use 'mysqld -O thread_stack=#' to specify a bigger stack." eng "Thread stack overrun: %ld bytes used of a %ld byte stack, and %ld bytes needed. Use 'mysqld -O thread_stack=#' to specify a bigger stack."
ER_TOO_LONG_BODY 42000 S1009 ER_TOO_LONG_BODY 42000 S1009
eng "Routine body for '%-.100s' is too long" eng "Routine body for '%-.100s' is too long"
ER_TOO_BIG_DISPLAYWIDTH 42000 S1009
eng "Display width out of range for column '%-.64s' (max = %d)"
...@@ -5819,7 +5819,7 @@ new_create_field(THD *thd, char *field_name, enum_field_types type, ...@@ -5819,7 +5819,7 @@ new_create_field(THD *thd, char *field_name, enum_field_types type,
new_field->length= 1; new_field->length= 1;
if (new_field->length > MAX_BIT_FIELD_LENGTH) if (new_field->length > MAX_BIT_FIELD_LENGTH)
{ {
my_error(ER_TOO_BIG_FIELDLENGTH, MYF(0), field_name, my_error(ER_TOO_BIG_DISPLAYWIDTH, MYF(0), field_name,
MAX_BIT_FIELD_LENGTH); MAX_BIT_FIELD_LENGTH);
DBUG_RETURN(NULL); DBUG_RETURN(NULL);
} }
...@@ -5838,7 +5838,10 @@ new_create_field(THD *thd, char *field_name, enum_field_types type, ...@@ -5838,7 +5838,10 @@ new_create_field(THD *thd, char *field_name, enum_field_types type,
type != MYSQL_TYPE_STRING && type != MYSQL_TYPE_STRING &&
type != MYSQL_TYPE_VARCHAR && type != FIELD_TYPE_GEOMETRY))) type != MYSQL_TYPE_VARCHAR && type != FIELD_TYPE_GEOMETRY)))
{ {
my_error(ER_TOO_BIG_FIELDLENGTH, MYF(0), my_error((type == MYSQL_TYPE_VAR_STRING || type == MYSQL_TYPE_VARCHAR ||
type == MYSQL_TYPE_STRING) ? ER_TOO_BIG_FIELDLENGTH :
ER_TOO_BIG_DISPLAYWIDTH,
MYF(0),
field_name, max_field_charlength); /* purecov: inspected */ field_name, max_field_charlength); /* purecov: inspected */
DBUG_RETURN(NULL); DBUG_RETURN(NULL);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment