diff options
author | Tor Didriksen <tor.didriksen@oracle.com> | 2011-07-18 11:21:14 +0200 |
---|---|---|
committer | Tor Didriksen <tor.didriksen@oracle.com> | 2011-07-18 11:21:14 +0200 |
commit | d72fefe98652646c82ab2ba0aba690c18e9b82c4 (patch) | |
tree | 28b394c9742e4dced4c6b2c8a429478342e430c4 /sql/item_func.cc | |
parent | 1a02a372432cbf023fa9291badf772f0f2bc55fd (diff) | |
download | mariadb-git-d72fefe98652646c82ab2ba0aba690c18e9b82c4.tar.gz |
Bug#12711164 - 61676: RESULT OF DIV WITH DECIMAL AND INTEGER DOES NOT MAKE SENSE
Truncate result of decimal division before converting to integer.
mysql-test/r/func_math.result:
New test case.
mysql-test/t/func_math.test:
New test case.
sql/item_func.cc:
Item_func_int_div::val_int():
Truncate result of decimal division before converting to integer.
Diffstat (limited to 'sql/item_func.cc')
-rw-r--r-- | sql/item_func.cc | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/sql/item_func.cc b/sql/item_func.cc index 19fc313a675..7257b411ec4 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -1605,8 +1605,13 @@ longlong Item_func_int_div::val_int() return 0; } + my_decimal truncated; + const bool do_truncate= true; + if (my_decimal_round(E_DEC_FATAL_ERROR, &tmp, 0, do_truncate, &truncated)) + DBUG_ASSERT(false); + longlong res; - if (my_decimal2int(E_DEC_FATAL_ERROR, &tmp, unsigned_flag, &res) & + if (my_decimal2int(E_DEC_FATAL_ERROR, &truncated, unsigned_flag, &res) & E_DEC_OVERFLOW) raise_integer_overflow(); return res; |