Skip to content

Index merge wrongly ignore some predicates of generated column #58476

@joechenrh

Description

@joechenrh

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

CREATE TABLE t3 (
  id int PRIMARY KEY,
  c1 varchar(256),
  c2 varchar(256) GENERATED ALWAYS AS (concat(c1, c1)) VIRTUAL,
  KEY (id)
);
 
insert into t3(id, c1) values (50, 'c');

SELECT /*+ USE_INDEX_MERGE(`t3`)*/ id FROM `t3` WHERE c2 BETWEEN 'a' AND 'b' GROUP BY id HAVING id < 100 or id > 0;

2. What did you expect to see? (Required)

Empty set

3. What did you see instead (Required)

mysql> SELECT /*+ USE_INDEX_MERGE(`t3`)*/ id FROM `t3` WHERE c2 BETWEEN 'a' AND 'b' GROUP BY id HAVING id < 100 or id > 0;
+----+
| id |
+----+
| 50 |
+----+
1 row in set (0.01 sec)

4. What is your TiDB version? (Required)

Metadata

Metadata

Assignees

Labels

affects-6.5This bug affects the 6.5.x(LTS) versions.affects-7.1This bug affects the 7.1.x(LTS) versions.affects-7.5This bug affects the 7.5.x(LTS) versions.affects-8.1This bug affects the 8.1.x(LTS) versions.affects-8.5This bug affects the 8.5.x(LTS) versions.fuzz/randomtestimpact/wrong-resultseverity/majorsig/plannerSIG: Plannertype/bugThe issue is confirmed as a bug.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions