mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 20:12:31 +01:00
Fix for bug #11708 (real function returns wrongly rounded decimal)
This commit is contained in:
parent
bf7515c302
commit
3ddd2771d6
4 changed files with 20 additions and 0 deletions
|
@ -937,3 +937,6 @@ drop table t1;
|
|||
select cast('1.00000001335143196001808973960578441619873046875E-10' as decimal(30,15));
|
||||
cast('1.00000001335143196001808973960578441619873046875E-10' as decimal(30,15))
|
||||
0.000000000100000
|
||||
select ln(14000) c1, convert(ln(14000),decimal(2,3)) c2, cast(ln(14000) as decimal(2,3)) c3;
|
||||
c1 c2 c3
|
||||
9.5468126085974 9.547 9.547
|
||||
|
|
|
@ -978,3 +978,8 @@ drop table t1;
|
|||
# Bug #10891 (converting to decimal crashes server)
|
||||
#
|
||||
select cast('1.00000001335143196001808973960578441619873046875E-10' as decimal(30,15));
|
||||
|
||||
#
|
||||
# Bug #11708 (conversion to decimal fails in decimal part)
|
||||
#
|
||||
select ln(14000) c1, convert(ln(14000),decimal(2,3)) c2, cast(ln(14000) as decimal(2,3)) c3;
|
||||
|
|
|
@ -566,6 +566,17 @@ String *Item_real_func::val_str(String *str)
|
|||
}
|
||||
|
||||
|
||||
my_decimal *Item_real_func::val_decimal(my_decimal *decimal_value)
|
||||
{
|
||||
DBUG_ASSERT(fixed);
|
||||
double nr= val_real();
|
||||
if (null_value)
|
||||
return 0; /* purecov: inspected */
|
||||
double2my_decimal(E_DEC_FATAL_ERROR, nr, decimal_value);
|
||||
return decimal_value;
|
||||
}
|
||||
|
||||
|
||||
void Item_func::fix_num_length_and_dec()
|
||||
{
|
||||
decimals= 0;
|
||||
|
|
|
@ -187,6 +187,7 @@ public:
|
|||
Item_real_func(Item *a,Item *b) :Item_func(a,b) {}
|
||||
Item_real_func(List<Item> &list) :Item_func(list) {}
|
||||
String *val_str(String*str);
|
||||
my_decimal *val_decimal(my_decimal *decimal_value);
|
||||
longlong val_int()
|
||||
{ DBUG_ASSERT(fixed == 1); return (longlong) val_real(); }
|
||||
enum Item_result result_type () const { return REAL_RESULT; }
|
||||
|
|
Loading…
Reference in a new issue