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
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