summaryrefslogtreecommitdiff
path: root/mysql-test/r/func_math.result
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/r/func_math.result
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/r/func_math.result')
-rw-r--r--mysql-test/r/func_math.result11
1 files changed, 11 insertions, 0 deletions
diff --git a/mysql-test/r/func_math.result b/mysql-test/r/func_math.result
index d8b8a14afc6..f469564c78b 100644
--- a/mysql-test/r/func_math.result
+++ b/mysql-test/r/func_math.result
@@ -382,6 +382,9 @@ y
SELECT b DIV 900 y FROM t1 GROUP BY y;
y
0
+Warnings:
+Warning 1366 Incorrect decimal value: '' for column '' at row -1
+Warning 1366 Incorrect decimal value: '' for column '' at row -1
SELECT c DIV 900 y FROM t1 GROUP BY y;
y
0
@@ -482,4 +485,12 @@ RAND(i)
0.155220427694936
DROP TABLE t1;
#
+select 123456789012345678901234567890.123456789012345678901234567890 div 1 as x;
+ERROR 22003: Out of range value for column 'x' at row 1
+select "123456789012345678901234567890.123456789012345678901234567890" div 1 as x;
+ERROR 22003: Out of range value for column 'x' at row 1
+SHOW WARNINGS;
+Level Code Message
+Warning 1292 Truncated incorrect DECIMAL value: ''
+Error 1264 Out of range value for column 'x' at row 1
End of 5.1 tests