| Bug #8457 | Precision math: DIV returns incorrect result with large decimal value | ||
|---|---|---|---|
| Submitted: | 11 Feb 2005 21:41 | Modified: | 11 Dec 20:30 |
| Reporter: | Trudy Pelzer | ||
| Status: | Closed | ||
| Category: | Server: DML | Severity: | S3 (Non-critical) |
| Version: | 5.0.3-alpha-debug | OS: | Linux (SuSE 9.1) |
| Assigned to: | Alexey Kopytov | Target Version: | 6.0-beta |
| Triage: | Triaged: D2 (Serious) | ||
[11 Feb 2005 21:41]
Trudy Pelzer
[11 Feb 2005 21:45]
Miguel Solorzano
Thank you for the bug report.
[29 Sep 2008 23:27]
Konstantin Osipov
We can issue errors from SELECT now.
[11 Dec 2008 16:27]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/61378 2922 Alexey Kopytov 2008-12-11 Fix 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.
[22 Dec 2008 13:45]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/62210 2714 Alexey Kopytov 2008-12-22 After-merge fix for bug #8457: correctly merged the results file.
[29 Dec 2008 16:39]
Bugs System
Pushed into 6.0.10-alpha (revid:sergefp@mysql.com-20081229085854-ui755edl9x4xomen) (version source revid:sergefp@mysql.com-20081227125220-feifj44ao5kapr93) (merge vers: 6.0.10-alpha) (pib:6)
[12 Jan 20:43]
Paul DuBois
Noted in 6.0.10 changelog. For the DIV operator, incorrect results could occur for non-integer operands that exceed BIGINT range. Now, if either operand has a non-integer type, the operands are converted to DECIMAL and divided using DECIMAL arithmetic before converting the result to BIGINT. If the result exceeds BIGINT range, an error occurs.
[13 Oct 10:32]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/86655 2896 Alexey Kopytov 2009-10-13 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.
[11 Dec 7:01]
Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20091211055901-yp18b3c7xuhl87rf) (version source revid:alik@sun.com-20091211055401-43rjwq7gjed6ds83) (merge vers: 6.0.14-alpha) (pib:13)
[11 Dec 20:30]
Paul DuBois
Already fixed in 6.0.x.
