Bug #71434 | DECIMAL `0.1` evaluates to TRUE in project list, FALSE in where/having clauses | ||
---|---|---|---|
Submitted: | 20 Jan 2014 21:24 | Modified: | 12 Nov 2019 23:00 |
Reporter: | Arthur O'Dwyer | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: DML | Severity: | S2 (Serious) |
Version: | 5.5.31, 5.5.35, 5.6.15, 5.1.73 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[20 Jan 2014 21:24]
Arthur O'Dwyer
[20 Jan 2014 21:30]
Arthur O'Dwyer
The same bug also applies to FLOAT and DOUBLE columns. Consider: CREATE TABLE foo (id <<<MYTYPE>>>); INSERT INTO foo VALUES (0.1); SELECT * FROM foo `a` JOIN foo `b`; -- yields one row SELECT * FROM foo `a` JOIN foo `b` WHERE a.id AND a.id; -- yields one row SELECT * FROM foo `a` JOIN foo `b` WHERE a.id AND b.id; -- yields empty set This gives inconsistent results whether <<<MYTYPE>>> is FLOAT, DOUBLE, or DECIMAL(2,1).
[21 Jan 2014 13:06]
MySQL Verification Team
Hello Arthur, Thank you for the report. Verified as described. Thanks, Umesh
[22 Jan 2014 7:58]
Roy Lyseng
Hi Arthur, there is a good workaround for this problem: Replace the column references with complete logical conditions, like this: SELECT d, NOT (d<>0), NOT NOT (d<>0) FROM t WHERE d<>0; SELECT d, NOT (d<>0), NOT NOT (d<>0) FROM t WHERE NOT (d<>0); SELECT d, NOT (d<>0), NOT NOT (d<>0) FROM t WHERE NOT NOT (d<>0); SELECT d, NOT (d<>0), NOT NOT (d<>0) FROM t WHERE NOT NOT NOT (d<>0); This substitution would also be the best internal fix, but unsure if it can be done easily.
[12 Nov 2019 23:00]
Roy Lyseng
Posted by developer: Problem has been fixed in 8.0 by worklog 12358 "Ensure that all predicates in SQL conditions are complete"