Bug #117095 The GREATEST function in the predicate behaves unexpectedly.
Submitted: 2 Jan 7:00 Modified: 2 Jan 7:23
Reporter: wang jack Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:8.4.1, 8.0.40 OS:Windows (windows 11)
Assigned to: CPU Architecture:x86 (x86_64)

[2 Jan 7:00] wang jack
Description:
Here are two queries, and I believe the first query should return one row of results.
Actually, the first query returned no results.

mysql> SELECT TRUE from t0 where (NOT ((t0.c0) OR (GREATEST(0.1, t0.c0, '-1849442274', t0.c0)))); -- empty
Empty set (0.00 sec)

mysql> SELECT (NOT ((t0.c0) OR (GREATEST(0.1, t0.c0, '-1849442274', t0.c0)))) from t0; -- {1}
+-----------------------------------------------------------------+
| (NOT ((t0.c0) OR (GREATEST(0.1, t0.c0, '-1849442274', t0.c0)))) |
+-----------------------------------------------------------------+
|                                                               1 |
+-----------------------------------------------------------------+
1 row in set (0.00 sec)

From my observation, this seems to be related to the ZEROFILL attribute.

How to repeat:
DROP TABLE IF EXISTS t0;
CREATE TABLE IF NOT EXISTS t0(c0 TINYINT ZEROFILL NOT NULL) ;
INSERT INTO t0(c0) VALUES(0);

SELECT t0.c0 FROM t0;

SELECT TRUE from t0 where (NOT ((t0.c0) OR (GREATEST(0.1, t0.c0, '-1849442274', t0.c0)))); -- empty
SELECT (NOT ((t0.c0) OR (GREATEST(0.1, t0.c0, '-1849442274', t0.c0)))) from t0; -- {1}
[2 Jan 7:23] MySQL Verification Team
Hello wang jack,

Thank you for the report and test case.

regards,
Umesh