summaryrefslogtreecommitdiff
path: root/mysql-test/t/func_math.test
diff options
context:
space:
mode:
authorAlexey Kopytov <Alexey.Kopytov@Sun.com>2009-10-13 12:31:42 +0400
committerAlexey Kopytov <Alexey.Kopytov@Sun.com>2009-10-13 12:31:42 +0400
commit7e3b4d21c0010bf6bc4fd8cdb8eee3caf8207f29 (patch)
treefea2364401dec8d958b129af9bc211c8ad3c9f96 /mysql-test/t/func_math.test
parent4337c3808f32c0851b7b9e6efb2516302d691bf8 (diff)
downloadmariadb-git-7e3b4d21c0010bf6bc4fd8cdb8eee3caf8207f29.tar.gz
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.
Diffstat (limited to 'mysql-test/t/func_math.test')
-rw-r--r--mysql-test/t/func_math.test11
1 files changed, 11 insertions, 0 deletions
diff --git a/mysql-test/t/func_math.test b/mysql-test/t/func_math.test
index 91fdce8addb..b999b1e8c1b 100644
--- a/mysql-test/t/func_math.test
+++ b/mysql-test/t/func_math.test
@@ -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