Commit defb3448 authored by unknown's avatar unknown

Merge bk-internal:/home/bk/mysql-4.0/

into serg.mylan:/usr/home/serg/Abk/mysql-4.0
parents 76e8a2b1 c110e445
...@@ -114,6 +114,9 @@ select min(a) from t1; ...@@ -114,6 +114,9 @@ select min(a) from t1;
min(a) min(a)
-0.010 -0.010
drop table t1; drop table t1;
create table t1 (c20 char);
insert into t1 (c20) values (5000.0);
drop table t1;
create table t1 (f float(54)); create table t1 (f float(54));
Incorrect column specifier for column 'f' Incorrect column specifier for column 'f'
drop table if exists t1; drop table if exists t1;
...@@ -54,6 +54,13 @@ select a from t1 order by a; ...@@ -54,6 +54,13 @@ select a from t1 order by a;
select min(a) from t1; select min(a) from t1;
drop table 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 # Errors
--error 1063 --error 1063
......
...@@ -3733,15 +3733,17 @@ static void store_double_in_string_field(Field_str *field, uint32 field_length, ...@@ -3733,15 +3733,17 @@ static void store_double_in_string_field(Field_str *field, uint32 field_length,
use_scientific_notation= (field->ceiling < nr); use_scientific_notation= (field->ceiling < nr);
} }
length= (uint)sprintf(buff, "%-.*g", 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); nr);
/* /*
+1 below is because "precision" in %g above means the +1 below is because "precision" in %g above means the
max. number of significant digits, not the output width. max. number of significant digits, not the output width.
Thus the width can be larger than number of significant digits by 1 Thus the width can be larger than number of significant digits by 1
(for decimal point) (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)); 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