Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query result may be wrong when use like to do index range scan on PAD SPACE column #48821

Closed
time-and-fate opened this issue Nov 23, 2023 · 0 comments · Fixed by #48845
Closed
Labels
affects-6.0 affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.2 affects-6.3 affects-6.4 affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-6.6 affects-7.0 affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.2 affects-7.3 affects-7.4 affects-7.5 This bug affects the 7.5.x(LTS) versions. severity/critical sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@time-and-fate
Copy link
Member

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create table t(a varchar(20) collate utf8mb4_bin, index ia(a));
insert into t value('测试'),('测试  ');
select *,length(a) from t where a like '测试 %';
select *,length(a) from t where a like '测试';

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

From mysql:

> select *,length(a) from t where a like '测试 %';
+----------+-----------+
| a        | length(a) |
+----------+-----------+
| 测试     |         8 |
+----------+-----------+

> select *,length(a) from t where a like '测试';
+--------+-----------+
| a      | length(a) |
+--------+-----------+
| 测试   |         6 |
+--------+-----------+

3. What did you see instead (Required)

> select *,length(a) from t use index () where a like '测试 %';
+----------+-----------+
| a        | length(a) |
+----------+-----------+
| 测试     |         8 |
+----------+-----------+

> select *,length(a) from t use index (ia) where a like '测试 %';
+----------+-----------+
| a        | length(a) |
+----------+-----------+
| 测试     |         6 |
| 测试     |         8 |
+----------+-----------+

> select *,length(a) from t use index () where a like '测试';
+--------+-----------+
| a      | length(a) |
+--------+-----------+
| 测试   |         6 |
+--------+-----------+

> select *,length(a) from t use index (ia) where a like '测试';
+----------+-----------+
| a        | length(a) |
+----------+-----------+
| 测试     |         6 |
| 测试     |         8 |
+----------+-----------+

4. What is your TiDB version? (Required)

From v6.0.0 to latest master

@time-and-fate time-and-fate added the type/bug The issue is confirmed as a bug. label Nov 23, 2023
@ti-chi-bot ti-chi-bot bot added may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 may-affects-6.5 may-affects-7.1 may-affects-7.5 labels Nov 23, 2023
@jebter jebter added sig/planner SIG: Planner and removed sig/sql-infra SIG: SQL Infra labels Nov 23, 2023
@time-and-fate time-and-fate removed may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. labels Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-6.0 affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.2 affects-6.3 affects-6.4 affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-6.6 affects-7.0 affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-7.2 affects-7.3 affects-7.4 affects-7.5 This bug affects the 7.5.x(LTS) versions. severity/critical sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
2 participants