Bug #119169 Inconsistent Result with DAYNAME() and DECIMAL
Submitted: 16 Oct 9:08
Reporter: zz z Email Updates:
Status: Open Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:9.4.0 8.4.6 OS:Any
Assigned to: CPU Architecture:Any

[16 Oct 9:08] zz z
Description:
A query yields inconsistent results between the optimized plan and the unoptimized count when a WHERE clause multiplies the string output of the DAYNAME() function by a DECIMAL column. The implicit cast of the DAYNAME() string to 0 should always result in a FALSE condition, but the unoptimized path incorrectly evaluates it as TRUE.

How to repeat:
CREATE TABLE t4668 (c1 DECIMAL(20,0));
ALTER TABLE t4668 RENAME t4669;
INSERT INTO t4669 (c1) VALUES (302);

SELECT c1 FROM t4669 WHERE (('Tuesday' * c1));
-- 0
SELECT SUM(count) FROM (SELECT ((('Tuesday' * c1))) IS TRUE AS count FROM t4669) AS ta_norec;
-- 1