Commit 490a1e28 authored by unknown's avatar unknown

Addition to fix for bug #12956: cast make differ rounding.

- use rint() in some other val_int() methods as well.

parent d54359ff
......@@ -2467,7 +2467,7 @@ longlong Item_param::val_int()
{
switch (state) {
case REAL_VALUE:
return (longlong) (value.real + (value.real > 0 ? 0.5 : -0.5));
return (longlong) rint(value.real);
case INT_VALUE:
return value.integer;
case DECIMAL_VALUE:
......@@ -5439,7 +5439,7 @@ void Item_cache_real::store(Item *item)
longlong Item_cache_real::val_int()
{
DBUG_ASSERT(fixed == 1);
return (longlong) (value+(value > 0 ? 0.5 : -0.5));
return (longlong) rint(value);
}
......
......@@ -199,7 +199,7 @@ public:
String *val_str(String*str);
my_decimal *val_decimal(my_decimal *decimal_value);
longlong val_int()
{ DBUG_ASSERT(fixed == 1); return (longlong) val_real(); }
{ DBUG_ASSERT(fixed == 1); return (longlong) rint(val_real()); }
enum Item_result result_type () const { return REAL_RESULT; }
void fix_length_and_dec()
{ decimals= NOT_FIXED_DEC; max_length= float_length(decimals); }
......@@ -943,7 +943,7 @@ class Item_func_udf_float :public Item_udf_func
longlong val_int()
{
DBUG_ASSERT(fixed == 1);
return (longlong) Item_func_udf_float::val_real();
return (longlong) rint(Item_func_udf_float::val_real());
}
my_decimal *val_decimal(my_decimal *dec_buf)
{
......
......@@ -452,7 +452,7 @@ longlong Item_sum_sum::val_int()
&result);
return result;
}
return (longlong) val_real();
return (longlong) rint(val_real());
}
......@@ -1285,7 +1285,7 @@ longlong Item_sum_hybrid::val_int()
return sum_int;
}
default:
return (longlong) Item_sum_hybrid::val_real();
return (longlong) rint(Item_sum_hybrid::val_real());
}
}
......@@ -2001,7 +2001,7 @@ double Item_avg_field::val_real()
longlong Item_avg_field::val_int()
{
return (longlong) val_real();
return (longlong) rint(val_real());
}
......
......@@ -126,7 +126,7 @@ public:
longlong val_int()
{
DBUG_ASSERT(fixed == 1);
return (longlong) val_real(); /* Real as default */
return (longlong) rint(val_real()); /* Real as default */
}
String *val_str(String*str);
my_decimal *val_decimal(my_decimal *);
......@@ -392,7 +392,7 @@ public:
bool add();
double val_real();
// In SPs we might force the "wrong" type with select into a declare variable
longlong val_int() { return (longlong)val_real(); }
longlong val_int() { return (longlong) rint(val_real()); }
my_decimal *val_decimal(my_decimal *);
String *val_str(String *str);
void reset_field();
......@@ -421,7 +421,7 @@ public:
enum Type type() const {return FIELD_VARIANCE_ITEM; }
double val_real();
longlong val_int()
{ /* can't be fix_fields()ed */ return (longlong) val_real(); }
{ /* can't be fix_fields()ed */ return (longlong) rint(val_real()); }
String *val_str(String*);
my_decimal *val_decimal(my_decimal *);
bool is_null() { (void) val_int(); return null_value; }
......@@ -699,7 +699,7 @@ class Item_sum_udf_float :public Item_udf_sum
longlong val_int()
{
DBUG_ASSERT(fixed == 1);
return (longlong) Item_sum_udf_float::val_real();
return (longlong) rint(Item_sum_udf_float::val_real());
}
double val_real();
String *val_str(String*str);
......
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