mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
Backport of the patch for bug #8457 "Precision math: DIV
returns incorrect result with large decimal value" For the DIV operator, neither operands nor result were checked for integer overflows. This patch changes the DIV behavior for non-integer operands as follows: if either of the operands has a non-integer type, convert both operands to the DECIMAL type, then calculate the division using DECIMAL arithmetics. Convert the resulting DECIMAL value into BIGINT [UNSIGNED] if it fits into the corresponding range, or throw an 'out of range' error otherwise. mysql-test/r/func_math.result: Added a test case for bug #8457. Fixed results for a test case depending on the wrong behavior. mysql-test/r/type_varchar.result: Fixed results for a test case depending on the wrong behavior. mysql-test/t/func_math.test: Added a test case for bug #8457. sql/item_func.cc: If either of the operands has a non-integer type, convert both operands to the DECIMAL type, then calculate the division using DECIMAL arithmetics. Convert the resulting DECIMAL value into BIGINT [UNSIGNED] if it fits into the corresponding range, or throw an 'out of range' error otherwise.
This commit is contained in:
@@ -309,4 +309,15 @@ DROP TABLE t1;
|
||||
|
||||
--echo #
|
||||
|
||||
#
|
||||
# Bug #8457: Precision math:
|
||||
# DIV returns incorrect result with large decimal value
|
||||
# Bug #46606:Casting error for large numbers in 5.4 when 'div' is used
|
||||
|
||||
--error ER_WARN_DATA_OUT_OF_RANGE
|
||||
select 123456789012345678901234567890.123456789012345678901234567890 div 1 as x;
|
||||
--error ER_WARN_DATA_OUT_OF_RANGE
|
||||
select "123456789012345678901234567890.123456789012345678901234567890" div 1 as x;
|
||||
SHOW WARNINGS;
|
||||
|
||||
--echo End of 5.1 tests
|
||||
|
||||
Reference in New Issue
Block a user