Bug #103145 | MySQL 8.0.22 decimal divide decimal has unexpected behavior | ||
---|---|---|---|
Submitted: | 30 Mar 2021 5:35 | Modified: | 30 Mar 2021 20:10 |
Reporter: | yu lei | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S3 (Non-critical) |
Version: | 8.0.22, 8.0.23 | OS: | Linux |
Assigned to: | CPU Architecture: | Any |
[30 Mar 2021 5:35]
yu lei
[30 Mar 2021 7:03]
MySQL Verification Team
Hello yu lei, Thank you for the report and test case. regards, Umesh
[30 Mar 2021 20:10]
Roy Lyseng
This is not a bug in 8.0. We changed handling of comparison conditions with incomplete predicates (e.g with a single numeric expression), as an inequality against zero. E.g. SELECT * FROM t WHERE a / 10000; is evaluated exactly like SELECT * FROM t WHERE a / 10000 <> 0; In some cases, this caused a slight deviation from results in 5.7. It may still look strange that (a/100000) is not equal to zero, however decimal operations in MySQL may internally be evaluated with greater precision than what is used externally. In the case of decimal division, the number of decimals used is 9, and thus the result is different from exact zero. If you want the *exact* intermediate result to have four decimals, you need to cast the division result to e.g. DECIMAL(10,4).