Bug #119343 NOT BETWEEN evaluates incorrectlywhen FROM_UNIXTIME operates on a FLOAT column

Submitted: 10 Nov 2025 8:40 Modified: 20 Nov 2025 11:18
Reporter: zz z Email Updates:
Status: Documenting Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S3 (Non-critical)
Version:8.0 OS:Any
Assigned to: CPU Architecture:Any

[10 Nov 2025 8:40] zz z
Description:
The evaluation of a NOT BETWEEN expression becomes inconsistent when its boundary is determined by a complex chain of functions. The core of the issue lies with FROM_UNIXTIME(t43.c2), where c2 is a FLOAT column. In a WHERE clause, this expression is correctly evaluated to TRUE. However, when the exact same expression is moved into the SELECT list of a derived table for boolean evaluation, the handling of FROM_UNIXTIME on the FLOAT column appears to be flawed, causing the entire NOT BETWEEN expression to be incorrectly evaluated as FALSE. This ultimately leads to the SUM aggregation returning 0 instead of the expected 1

How to repeat:
CREATE TABLE t43 (c1 VARCHAR (14), c2 FLOAT);
INSERT t43 () VALUES ('BR',1.009);

SELECT 'BR' FROM t43 WHERE '2014-12-20 13:10:23' NOT BETWEEN '2010-06-07' AND TIMESTAMP((FROM_UNIXTIME(t43.c2)), (DATE_SUB(('2014-12-19'), INTERVAL 5 YEAR)));
-- BR
SELECT SUM(count) FROM (SELECT ('2014-12-20 13:10:23' NOT BETWEEN '2010-06-07' AND TIMESTAMP((FROM_UNIXTIME(t43.c2)), (DATE_SUB(('2014-12-19'), INTERVAL 5 YEAR)))) IS TRUE AS count FROM t43) AS ta_norec;
-- 0
[20 Nov 2025 11:18] Roy Lyseng
Verified as described on 8.0 and 8.4.
Seems ro be correct on 9.x.
[22 Dec 2025 20:51] Roy Lyseng
Posted by developer:
 
Fixed by worklog #16790: Refactor TIME handling in server
[28 May 1:13] MySQL Admin
Posted by developer: Bug status updated to 'Documenting'

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.