Bug #118310 a query with a impossile having clause, return wrong results
Description:
a query with a impossile having clause, return wrong results
mysql> select ((NULLIF(-430099078, AVG(SCHEMA()))) IS NULL) from t0;
+-----------------------------------------------+
| ((NULLIF(-430099078, AVG(SCHEMA()))) IS NULL) |
+-----------------------------------------------+
| 0 |
+-----------------------------------------------+
1 row in set, 3 warnings (0.00 sec)
mysql> SELECT /*+ READ_FROM_STORAGE(TIFLASH[t0])*/t0.c0 FROM t0 WHERE t0.c0 GROUP BY t0.c0 HAVING 0;
Empty set, 1 warning (0.00 sec)
mysql> SELECT /*+ READ_FROM_STORAGE(TIFLASH[t0])*/t0.c0 FROM t0 WHERE t0.c0 GROUP BY t0.c0 HAVING ((NULLIF(-430099078, AVG(SCHEMA()))) IS NULL);
+------------+
| c0 |
+------------+
| -589456629 |
| -503198307 |
| 662364767 |
+------------+
3 rows in set, 1 warning (0.00 sec)
How to repeat:
CREATE DATABASE /*!32312 IF NOT EXISTS*/ `tidb202505291` /*!40100 DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci */ /*!80016 DEFAULT ENCRYPTION='N' */;
USE `tidb202505291`;
DROP TABLE IF EXISTS `t0`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `t0` (
`c0` decimal(10,0) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
INSERT INTO `t0` VALUES (-589456629),(-503198307),(662364767);
SELECT /*+ READ_FROM_STORAGE(TIFLASH[t0])*/t0.c0 FROM t0 WHERE t0.c0 GROUP BY t0.c0 HAVING 0;
SELECT /*+ READ_FROM_STORAGE(TIFLASH[t0])*/t0.c0 FROM t0 WHERE t0.c0 GROUP BY t0.c0 HAVING ((NULLIF(-430099078, AVG(SCHEMA()))) IS NULL);
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.