USE_INDEX_MERGE results in an incorrect result for a generated column #15994
Closed
Description
Consider the following statements:
CREATE TABLE t0(c0 INT AS (1), c1 INT PRIMARY KEY);
INSERT INTO t0(c1) VALUES (0);
CREATE INDEX i0 ON t0(c0);
SELECT /*+ USE_INDEX_MERGE(t0, i0, PRIMARY)*/ t0.c0 FROM t0 WHERE t0.c1 OR t0.c0;
SELECT t0.c0 FROM t0 WHERE t0.c1 OR t0.c0; -- expected: {1}, actual: {NULL}
Unexpectedly, an incorrect value for c0
is returned. When removing the USE_INDEX_MERGE
hint, the correct result is computed:
CREATE TABLE t0(c0 INT AS (1), c1 INT PRIMARY KEY);
INSERT INTO t0(c1) VALUES (0);
CREATE INDEX i0 ON t0(c0);
SELECT t0.c0 FROM t0 WHERE t0.c1 OR t0.c0; -- {1}
Environment:
mysql> select tidb_version();
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version() |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v4.0.0-beta.2-160-g82529c886
Git Commit Hash: 82529c886cb1cfff7810476a136acf81284bac6e
Git Branch: master
UTC Build Time: 2020-04-01 11:44:27
GoVersion: go1.13.4
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |
+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
Activity