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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment