Commit 432a0f36 authored by unknown's avatar unknown

less strict assert to take into account weird cases

parent f1cf7c13
......@@ -114,6 +114,9 @@ select min(a) from t1;
min(a)
-0.010
drop table t1;
create table t1 (c20 char);
insert into t1 (c20) values (5000.0);
drop table t1;
create table t1 (f float(54));
Incorrect column specifier for column 'f'
drop table if exists t1;
......@@ -54,6 +54,13 @@ select a from t1 order by a;
select min(a) from t1;
drop table t1;
#
# float in a char(1) field
#
create table t1 (c20 char);
insert into t1 (c20) values (5000.0);
drop table t1;
# Errors
--error 1063
......
......@@ -3733,15 +3733,17 @@ static void store_double_in_string_field(Field_str *field, uint32 field_length,
use_scientific_notation= (field->ceiling < nr);
}
length= (uint)sprintf(buff, "%-.*g",
use_scientific_notation ? max(0,field_length-5) : field_length,
use_scientific_notation ? max(0,(int)field_length-5) : field_length,
nr);
/*
+1 below is because "precision" in %g above means the
max. number of significant digits, not the output width.
Thus the width can be larger than number of significant digits by 1
(for decimal point)
the test for field_length < 5 is for extreme cases,
like inserting 500.0 in char(1)
*/
DBUG_ASSERT(length <= field_length+1);
DBUG_ASSERT(field_length < 5 || length <= field_length+1);
field->store(buff, min(length, field_length));
}
......
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