Bug #118571 using index lookup, the query return a wrong result;

Submitted: 2 Jul 2025 7:27 Modified: 6 Aug 2025 12:50
Reporter: SamonBing SamonBing Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Server: DML Severity:S3 (Non-critical)
Version:8.0.41 OS:Any
Assigned to: CPU Architecture:Any

[2 Jul 2025 7:27] SamonBing SamonBing
Description:
using index lookup, the query return a wrong result;
after dropping the index, the same query return a right result.

How to repeat:
drop table if exists test_table;
CREATE TABLE `test_table` (
  `c0` tinyint(1) NOT NULL,
  KEY `i0` (`c0`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
/*!40101 SET character_set_client = @saved_cs_client */;

INSERT INTO `test_table` VALUES (0),(0),(0);
/*!40000 ALTER TABLE `test_table` ENABLE KEYS */;

-- return a wrong result
SELECT test_table.c0,((SIN(1742704984))=(test_table.c0)) FROM test_table WHERE ((SIN(1742704984))=(test_table.c0)) GROUP BY test_table.c0 HAVING (NOT (MAX((BINARY (test_table.c0)))));

mysql> SELECT test_table.c0,((SIN(1742704984))=(test_table.c0)) FROM test_table WHERE ((SIN(1742704984))=(test_table.c0)) GROUP BY test_table.c0 HAVING (NOT (MAX((BINARY (test_table.c0)))));
+----+-------------------------------------+
| c0 | ((SIN(1742704984))=(test_table.c0)) |
+----+-------------------------------------+
|  0 |                                   0 |
+----+-------------------------------------+

alter table test_table drop index i0;

-- return a right result
SELECT test_table.c0,((SIN(1742704984))=(test_table.c0)) FROM test_table WHERE ((SIN(1742704984))=(test_table.c0)) GROUP BY test_table.c0 HAVING (NOT (MAX((BINARY (test_table.c0)))));

mysql> SELECT test_table.c0,((SIN(1742704984))=(test_table.c0)) FROM test_table WHERE ((SIN(1742704984))=(test_table.c0)) GROUP BY test_table.c0 HAVING (NOT (MAX((BINARY (test_table.c0)))));
Empty set, 1 warning (0.00 sec)
[6 Aug 2025 12:50] MySQL Verification Team
Hello SamonBing,

Thank you for the bug report.
Imho this is duplicate of Bug #118092, please see Bug #118092.

Regards,
Ashwini Patil

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.