Bug #119326 Using the COALESCE function, two opposite conditions return the same result.

Submitted: 7 Nov 2025 7:40 Modified: 7 Nov 2025 9:05
Reporter: Go Yakult Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Optimizer Severity:S3 (Non-critical)
Version:8.0.41 OS:Any
Assigned to: CPU Architecture:Any

[7 Nov 2025 7:40] Go Yakult
Description:
mysql> SELECT t0.c0, t0.c1 FROM t0 WHERE (t0.c0) NOT IN (COALESCE(NULL, 0.5465051074331168));
+------+-------------+
| c0   | c1          |
+------+-------------+
|    1 | 0.758446682 |
+------+-------------+
1 row in set (0.000 sec)

mysql> SELECT t0.c0, t0.c1 FROM t0 WHERE (NOT ((t0.c0) NOT IN (COALESCE(NULL, 0.5465051074331168))));
+------+-------------+
| c0   | c1          |
+------+-------------+
|    1 | 0.758446682 |
+------+-------------+
1 row in set (0.000 sec)

How to repeat:
DROP TABLE IF EXISTS `t0`;
CREATE TABLE `t0` (
  `c0` tinyint DEFAULT NULL COMMENT 'asdf',
  `c1` decimal(9,9) NOT NULL COMMENT 'asdf',
  PRIMARY KEY (`c1`),
  KEY `i0` (`c1`) USING BTREE,
  KEY `i1` (`c0`)
);

INSERT INTO `t0` VALUES(1,0.758446682);

SELECT t0.c0, t0.c1 FROM t0 WHERE (t0.c0) NOT IN (COALESCE(NULL, 0.5465051074331168));
SELECT t0.c0, t0.c1 FROM t0 WHERE (NOT ((t0.c0) NOT IN (COALESCE(NULL, 0.5465051074331168))));

Suggested fix:
After removing the COALESCE function, the result becomes correct — so it’s probably the issue, right?
[7 Nov 2025 9:05] Roy Lyseng
Verified as described.

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

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