summaryrefslogtreecommitdiff
path: root/sql/item_sum.h
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2018-09-20 16:02:58 +0400
committerAlexander Barkov <bar@mariadb.com>2018-09-20 16:02:58 +0400
commit0c6455aa4658790439a58956f05df200a5e380b8 (patch)
treeb792c811420d76f7b6edc079f1a7e9923aebe9b0 /sql/item_sum.h
parente43bc02e7b2752f0deb88cd1edc24d827e01dca9 (diff)
downloadmariadb-git-0c6455aa4658790439a58956f05df200a5e380b8.tar.gz
MDEV-17249 MAKETIME(-1e50,0,0) returns a wrong result
Diffstat (limited to 'sql/item_sum.h')
-rw-r--r--sql/item_sum.h19
1 files changed, 15 insertions, 4 deletions
diff --git a/sql/item_sum.h b/sql/item_sum.h
index dcc3e494f82..b0bca5e7ad2 100644
--- a/sql/item_sum.h
+++ b/sql/item_sum.h
@@ -699,7 +699,9 @@ public:
longlong val_int()
{
DBUG_ASSERT(fixed == 1);
- return (longlong) rint(val_real()); /* Real as default */
+ // Real as default
+ bool error;
+ return double_to_longlong(val_real(), unsigned_flag, &error);
}
String *val_str(String*str);
my_decimal *val_decimal(my_decimal *);
@@ -867,7 +869,11 @@ 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) rint(val_real()); }
+ longlong val_int()
+ {
+ bool error;
+ return double_to_longlong(val_real(), unsigned_flag, &error);
+ }
my_decimal *val_decimal(my_decimal *);
String *val_str(String *str);
void reset_field();
@@ -904,7 +910,10 @@ public:
enum Type type() const {return FIELD_VARIANCE_ITEM; }
double val_real();
longlong val_int()
- { /* can't be fix_fields()ed */ return (longlong) rint(val_real()); }
+ { /* can't be fix_fields()ed */
+ bool error;
+ return double_to_longlong(val_real(), unsigned_flag, &error);
+ }
String *val_str(String *str)
{ return val_string_from_real(str); }
my_decimal *val_decimal(my_decimal *dec_buf)
@@ -1215,7 +1224,9 @@ class Item_sum_udf_float :public Item_udf_sum
longlong val_int()
{
DBUG_ASSERT(fixed == 1);
- return (longlong) rint(Item_sum_udf_float::val_real());
+ bool error;
+ return double_to_longlong(Item_sum_udf_float::val_real(),
+ unsigned_flag, &error);
}
double val_real();
String *val_str(String*str);