Bug #119583 Create index can lead to incorrect results

Submitted: 22 Dec 2025 7:34 Modified: 22 Dec 2025 19:35
Reporter: fan liu Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S3 (Non-critical)
Version:8.0.44 OS:Any
Assigned to: CPU Architecture:Any

[22 Dec 2025 7:34] fan liu
Description:
The same query returned different results after I created the index.

CREATE TABLE t0(c0 FLOAT);

CREATE TABLE IF NOT EXISTS t1 LIKE t0;

INSERT INTO t1(c0) VALUES(-1811968123),(-662745492);

INSERT INTO t0(c0) VALUES(-1811968123),(-662745492),(0);

SELECT ALL t1.c0, t0.c0 FROM t0, t1 WHERE (t0.c0) IN (IF(NULL, "'K", t1.c0));
-1811970000	-1811970000
-662745000	-662745000

CREATE UNIQUE INDEX i0 ON t0(c0);

SELECT ALL t1.c0, t0.c0 FROM t0, t1 WHERE (t0.c0) IN (IF(NULL, "'K", t1.c0));
Empty set;

How to repeat:
CREATE TABLE t0(c0 FLOAT);

CREATE TABLE IF NOT EXISTS t1 LIKE t0;

INSERT INTO t1(c0) VALUES(-1811968123),(-662745492);

INSERT INTO t0(c0) VALUES(-1811968123),(-662745492),(0);

SELECT ALL t1.c0, t0.c0 FROM t0, t1 WHERE (t0.c0) IN (IF(NULL, "'K", t1.c0));

CREATE UNIQUE INDEX i0 ON t0(c0);

SELECT ALL t1.c0, t0.c0 FROM t0, t1 WHERE (t0.c0) IN (IF(NULL, "'K", t1.c0));
[22 Dec 2025 19:35] Roy Lyseng
Verified as described.
Note however that using inexact data types like FLOAT and DOUBLE may cause
precision problems in comparisons, so that result of equality operations
may seem incorrect.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.048 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.