summaryrefslogtreecommitdiff
path: root/sql/field.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/field.cc')
-rw-r--r--sql/field.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/sql/field.cc b/sql/field.cc
index f8ab4b852ec..99e9d7803e1 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -5987,13 +5987,13 @@ int Field_str::store(double nr)
calculate the maximum number of significant digits if the 'f'-format
would be used (+1 for decimal point if the number has a fractional part).
*/
- digits= max(0, (int) max_length - fractional);
+ digits= max(1, (int) max_length - fractional);
/*
If the exponent is negative, decrease digits by the number of leading zeros
after the decimal point that do not count as significant digits.
*/
if (exp < 0)
- digits= max(0, (int) digits + exp);
+ digits= max(1, (int) digits + exp);
/*
'e'-format is used only if the exponent is less than -4 or greater than or
equal to the precision. In this case we need to adjust the number of
@@ -6001,7 +6001,7 @@ int Field_str::store(double nr)
We also have to reserve one additional character if abs(exp) >= 100.
*/
if (exp >= (int) digits || exp < -4)
- digits= max(0, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
+ digits= max(1, (int) (max_length - 5 - (exp >= 100 || exp <= -100)));
/* Limit precision to DBL_DIG to avoid garbage past significant digits */
set_if_smaller(digits, DBL_DIG);
@@ -8587,16 +8587,16 @@ bool create_field::init(THD *thd, char *fld_name, enum_field_types fld_type,
else if (tmp_length > PRECISION_FOR_FLOAT)
{
sql_type= FIELD_TYPE_DOUBLE;
- length= DBL_DIG+7; /* -[digits].E+### */
+ length= MAX_DOUBLE_STR_LENGTH;
}
else
- length= FLT_DIG+6; /* -[digits].E+## */
+ length= MAX_FLOAT_STR_LENGTH;
decimals= NOT_FIXED_DEC;
break;
}
if (!fld_length && !fld_decimals)
{
- length= FLT_DIG+6;
+ length= MAX_FLOAT_STR_LENGTH;
decimals= NOT_FIXED_DEC;
}
if (length < decimals &&