Bug #119136 Incompatible behavior between integer columns when comparing with datetime
| Submitted: | 13 Oct 2025 3:14 | Modified: | 22 Apr 21:05 |
|---|---|---|---|
| Reporter: | John Jove | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server: Optimizer | Severity: | S2 (Serious) |
| Version: | 8.0 | OS: | Any |
| Assigned to: | CPU Architecture: | Any |
[6 Jan 14:15]
Roy Lyseng
Thank you for the bug report. Verified as described.
[22 Apr 21:05]
Edward Gilmore
Posted by developer: Added the following note to the MySQL Server 9.7.0 release notes: Datetime comparisons were inconsistent depending on the type used to store the values, INT or BIGINT.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.039 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
Description: I try to store the same value 1 into integer columns with different type, i.e., INT and BIGINT. Then, I try to compare the value with a DATETIME value. However, the server returns inconsistent outputs. How to repeat: -- Run the following cases. DROP TABLE t1; CREATE TABLE t1 (c1 INT); INSERT INTO t1 VALUES (1); SELECT (c1 = CAST(0.0 AS DATETIME)) FROM t1; -- {NULL} DROP TABLE t1; CREATE TABLE t1 (c1 BIGINT); INSERT INTO t1 VALUES (1); SELECT (c1 = CAST(0.0 AS DATETIME)) FROM t1; -- {0}