Bug #118394 while (NOT XX NOT IN ()) return 0, the query with where (NOT XX NOT IN ()) returns a wrong result.

Submitted: 9 Jun 2025 2:04 Modified: 5 Feb 22:17
Reporter: SamonBing SamonBing 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

[9 Jun 2025 2:04] SamonBing SamonBing
Description:
while (NOT XX NOT IN ()) return 0, the query with where (NOT XX NOT IN ()) returns a wrong result.

mysql> SELECT t0.c4,((t0.c4) NOT IN(LEAST('-1415217693', "1761785550"))),(NOT ((t0.c4) NOT IN(LEAST('-1415217693', "1761785550")))) FROM t0 WHERE (NOT ((t0.c4) NOT IN(LEAST('-1415217693', "1761785550"))));
+------------------------+------------------------------------------------------+------------------------------------------------------------+
| c4                     | ((t0.c4) NOT IN(LEAST('-1415217693', "1761785550"))) | (NOT ((t0.c4) NOT IN(LEAST('-1415217693', "1761785550")))) |
+------------------------+------------------------------------------------------+------------------------------------------------------------+
| 0000000000000000000000 |                                                    1 |                                                          0 |
+------------------------+------------------------------------------------------+------------------------------------------------------------+
1 row in set (0.00 sec)

How to repeat:
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `tlp2025060615` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */ /*!80016 DEFAULT ENCRYPTION='N' */;

USE `tlp2025060615`;

DROP TABLE IF EXISTS `t0`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `t0` (
  `c0` float unsigned zerofill /*!50606 STORAGE MEMORY */ /*!50606 COLUMN_FORMAT FIXED */ DEFAULT NULL,
  `c1` varchar(500) /*!50606 STORAGE MEMORY */ /*!50606 COLUMN_FORMAT FIXED */ DEFAULT NULL COMMENT 'asdf',
  `c2` varchar(500) /*!50606 STORAGE MEMORY */ DEFAULT NULL COMMENT 'asdf',
  `c3` bigint /*!50606 STORAGE MEMORY */ DEFAULT NULL COMMENT 'asdf',
  `c4` double unsigned zerofill /*!50606 STORAGE MEMORY */ DEFAULT NULL COMMENT 'asdf',
  UNIQUE KEY `c3` (`c3`),
  UNIQUE KEY `i0` (`c4`,`c0`,`c1` DESC,`c2`(3)),
  UNIQUE KEY `i2` (`c0` DESC,`c1`(2),`c3` DESC,`c4` DESC,`c2`) USING BTREE,
  UNIQUE KEY `i3` (`c3`,`c1`(3),`c4` DESC,`c2`),
  KEY `i1` (`c0`) /*!80000 INVISIBLE */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

INSERT INTO `t0` VALUES (000000000000,'',NULL,896771624,0000000000000000000000);

mysql> SELECT t0.c4,((t0.c4) NOT IN(LEAST('-1415217693', "1761785550"))),(NOT ((t0.c4) NOT IN(LEAST('-1415217693', "1761785550")))) FROM t0 WHERE (NOT ((t0.c4) NOT IN(LEAST('-1415217693', "1761785550"))));
+------------------------+------------------------------------------------------+------------------------------------------------------------+
| c4                     | ((t0.c4) NOT IN(LEAST('-1415217693', "1761785550"))) | (NOT ((t0.c4) NOT IN(LEAST('-1415217693', "1761785550")))) |
+------------------------+------------------------------------------------------+------------------------------------------------------------+
| 0000000000000000000000 |                                                    1 |                                                          0 |
+------------------------+------------------------------------------------------+------------------------------------------------------------+
1 row in set (0.00 sec)
[5 Feb 22:17] Roy Lyseng
Thank you for the bug report.
Verified as described.

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

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