Hi, there is a new issue found by the code in #6104.
The inputs are as follows:
schema_ddl:
DROP TABLE IF EXISTS `t0`;
CREATE TABLE `t0` (
`c0` decimal(10,0) DEFAULT NULL
) ;
INSERT INTO `t0` VALUES (0);
DROP TABLE IF EXISTS `t2`;
CREATE TABLE `t2` (
`c0` decimal(10,0) DEFAULT NULL
) ;
INSERT INTO `t2` VALUES (NULL),(NULL),(NULL),(-1133322562),(924447850);
raw_sql:
SELECT ALL (0.2490851303242515) && (t2.c0) AS ref0 FROM t2 WHERE (+ (0.7725118729820029)) LIMIT 1515426352;
Then I got the optimized sql:
SELECT `t2`.`c0` AS `ref0` FROM `t2` AS `t2` LIMIT 1515426352;
The execution result in MySQL 8.0.4:
The result of raw sql:
+------+
| ref0 |
+------+
| NULL |
| NULL |
| NULL |
| 1 |
| 1 |
+------+
5 rows in set, 1 warning (0.00 sec)
The result of optimized sql:
+-------------+
| ref0 |
+-------------+
| NULL |
| NULL |
| NULL |
| -1133322562 |
| 924447850 |
+-------------+
5 rows in set (0.00 sec)
The optimizer incorrectly simplifies the logical expression (CONSTANT) && (t2.c0) in the SELECT list to just t2.c0.