diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2020-03-20 15:37:08 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2020-03-20 15:51:30 +0200 |
commit | c9ec1cc751df936d3359e0705f4341a814b2b4fa (patch) | |
tree | e1ed643823118af2d254a23878932c8f1e9965b8 /sql/item_func.cc | |
parent | a66eebf57c212363f9f430a4c8c9a4f3ddf57cfb (diff) | |
parent | 328edf8560dbf1941ce314fa112e0db05d9f97f1 (diff) | |
download | mariadb-git-c9ec1cc751df936d3359e0705f4341a814b2b4fa.tar.gz |
Merge 10.1 into 10.2
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r-- | sql/item_func.cc | 33 |
1 files changed, 10 insertions, 23 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc index 825af76ef15..5a4c7aeab3e 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1817,11 +1817,9 @@ longlong Item_func_int_div::val_int() raise_integer_overflow(); return res; } - - longlong val0=args[0]->val_int(); - longlong val1=args[1]->val_int(); - bool val0_negative, val1_negative, res_negative; - ulonglong uval0, uval1, res; + + Longlong_hybrid val0= args[0]->to_longlong_hybrid(); + Longlong_hybrid val1= args[1]->to_longlong_hybrid(); if ((null_value= (args[0]->null_value || args[1]->null_value))) return 0; if (val1 == 0) @@ -1830,12 +1828,8 @@ longlong Item_func_int_div::val_int() return 0; } - val0_negative= !args[0]->unsigned_flag && val0 < 0; - val1_negative= !args[1]->unsigned_flag && val1 < 0; - res_negative= val0_negative != val1_negative; - uval0= (ulonglong) (val0_negative ? -val0 : val0); - uval1= (ulonglong) (val1_negative ? -val1 : val1); - res= uval0 / uval1; + bool res_negative= val0.neg() != val1.neg(); + ulonglong res= val0.abs() / val1.abs(); if (res_negative) { if (res > (ulonglong) LONGLONG_MAX) @@ -1864,11 +1858,8 @@ bool Item_func_int_div::fix_length_and_dec() longlong Item_func_mod::int_op() { DBUG_ASSERT(fixed == 1); - longlong val0= args[0]->val_int(); - longlong val1= args[1]->val_int(); - bool val0_negative, val1_negative; - ulonglong uval0, uval1; - ulonglong res; + Longlong_hybrid val0= args[0]->to_longlong_hybrid(); + Longlong_hybrid val1= args[1]->to_longlong_hybrid(); if ((null_value= args[0]->null_value || args[1]->null_value)) return 0; /* purecov: inspected */ @@ -1883,13 +1874,9 @@ longlong Item_func_mod::int_op() LONGLONG_MIN by -1 generates SIGFPE, we calculate using unsigned values and then adjust the sign appropriately. */ - val0_negative= !args[0]->unsigned_flag && val0 < 0; - val1_negative= !args[1]->unsigned_flag && val1 < 0; - uval0= (ulonglong) (val0_negative ? -val0 : val0); - uval1= (ulonglong) (val1_negative ? -val1 : val1); - res= uval0 % uval1; - return check_integer_overflow(val0_negative ? -(longlong) res : res, - !val0_negative); + ulonglong res= val0.abs() % val1.abs(); + return check_integer_overflow(val0.neg() ? -(longlong) res : res, + !val0.neg()); } double Item_func_mod::real_op() |