mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Fix for bug #12694 (float(1,2) field error)
mysql-test/t/type_float.test: test case sql/sql_parse.cc: length & dec checks added
This commit is contained in:
@ -147,3 +147,12 @@ select * from t1 where reckey=1.09E2;
|
|||||||
drop table t1;
|
drop table t1;
|
||||||
|
|
||||||
# End of 4.1 tests
|
# End of 4.1 tests
|
||||||
|
|
||||||
|
#
|
||||||
|
# bug #12694 (float(m,d) specifications)
|
||||||
|
#
|
||||||
|
|
||||||
|
--error 1427
|
||||||
|
create table t1 (s1 float(0,2));
|
||||||
|
--error 1427
|
||||||
|
create table t1 (s1 float(1,2));
|
||||||
|
@ -5752,19 +5752,31 @@ new_create_field(THD *thd, char *field_name, enum_field_types type,
|
|||||||
new_field->decimals= NOT_FIXED_DEC;
|
new_field->decimals= NOT_FIXED_DEC;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (!length)
|
if (!length && !decimals)
|
||||||
{
|
{
|
||||||
new_field->length = FLT_DIG+6;
|
new_field->length = FLT_DIG+6;
|
||||||
new_field->decimals= NOT_FIXED_DEC;
|
new_field->decimals= NOT_FIXED_DEC;
|
||||||
}
|
}
|
||||||
|
if (new_field->length < new_field->decimals &&
|
||||||
|
new_field->decimals != NOT_FIXED_DEC)
|
||||||
|
{
|
||||||
|
my_error(ER_SCALE_BIGGER_THAN_PRECISION, MYF(0), field_name);
|
||||||
|
DBUG_RETURN(NULL);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case FIELD_TYPE_DOUBLE:
|
case FIELD_TYPE_DOUBLE:
|
||||||
allowed_type_modifier= AUTO_INCREMENT_FLAG;
|
allowed_type_modifier= AUTO_INCREMENT_FLAG;
|
||||||
if (!length)
|
if (!length && !decimals)
|
||||||
{
|
{
|
||||||
new_field->length = DBL_DIG+7;
|
new_field->length = DBL_DIG+7;
|
||||||
new_field->decimals=NOT_FIXED_DEC;
|
new_field->decimals=NOT_FIXED_DEC;
|
||||||
}
|
}
|
||||||
|
if (new_field->length < new_field->decimals &&
|
||||||
|
new_field->decimals != NOT_FIXED_DEC)
|
||||||
|
{
|
||||||
|
my_error(ER_SCALE_BIGGER_THAN_PRECISION, MYF(0), field_name);
|
||||||
|
DBUG_RETURN(NULL);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case FIELD_TYPE_TIMESTAMP:
|
case FIELD_TYPE_TIMESTAMP:
|
||||||
if (!length)
|
if (!length)
|
||||||
|
Reference in New Issue
Block a user