CREATE TABLE t0(c0 INT, c1 INT);
CREATE INDEX i0 ON t0(c0, c1);
INSERT INTO t0 VALUES (0, 0);
SELECT /*+ USE_INDEX(t0, i0, i0)*/t0.c0 FROM t0 WHERE t0.c1; -- expected: {}, actual: {0}
Unexpectedly, when using the index hint, the row is fetched:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.25-TiDB- TiDB Server (Apache License 2.0), MySQL 5.7 compatible
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> CREATE TABLE t0(c0 INT, c1 INT);
Query OK, 0 rows affected (0.00 sec)
mysql> CREATE INDEX i0 ON t0(c0, c1);
Query OK, 0 rows affected (0.00 sec)
mysql> INSERT INTO t0 VALUES (0, 0);
Query OK, 1 row affected (0.00 sec)
mysql> SELECT /*+ USE_INDEX(t0, i0, i0)*/t0.c0 FROM t0 WHERE t0.c1;
+------+
| c0 |
+------+
| 0 |
+------+
1 row in set (0.00 sec)
When omitting the hint, or specifying i0 only once, the row is not fetched, as expected. I found this bug based on the latest master commit b6fcc157442894f048c1cc65cfcc7776e9ed1a72, and checked that it is also reproducible for the 4.0 RC.
Consider the following statements:
Unexpectedly, when using the index hint, the row is fetched:
When omitting the hint, or specifying
i0
only once, the row is not fetched, as expected. I found this bug based on the latest master commit b6fcc157442894f048c1cc65cfcc7776e9ed1a72, and checked that it is also reproducible for the 4.0 RC.