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

wrong result when optimize order by for index #30271

Closed
wjhuang2016 opened this issue Nov 30, 2021 · 3 comments · Fixed by #30273
Closed

wrong result when optimize order by for index #30271

wjhuang2016 opened this issue Nov 30, 2021 · 3 comments · Fixed by #30273
Labels
affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. type/bug The issue is confirmed as a bug.

Comments

@wjhuang2016
Copy link
Member

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

create table t(a char(10), b char(10), c char(10), index (a, b, c)) collate utf8mb4_bin;
insert into t values ("b", "a", "1"), ("b", "A", "2"), ("c", "a", "3");
set names utf8mb4 collate utf8mb4_general_ci;
select * from t where (a>"a" and b="a") or (b = "A" and a < "d") order by a,c;

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

+------+------+------+
| a    | b    | c    |
+------+------+------+
| b    | a    | 1    |
| b    | A    | 2    |
| c    | a    | 3    |
+------+------+------+

3. What did you see instead (Required)

mysql> select * from t where (a>"a" and b="a") or (b = "A" and a < "d") order by a,c;
+------+------+------+
| a    | b    | c    |
+------+------+------+
| b    | A    | 2    |
| b    | a    | 1    |
| c    | a    | 3    |
+------+------+------+
3 rows in set (0.00 sec)

4. What is your TiDB version? (Required)

master

@xuyifangreeneyes
Copy link
Contributor

/label affects-5.2

@ti-chi-bot ti-chi-bot added the affects-5.2 This bug affects 5.2.x versions. label Nov 30, 2021
@xuyifangreeneyes
Copy link
Contributor

/label affects-5.3

@ti-chi-bot ti-chi-bot added the affects-5.3 This bug affects 5.3.x versions. label Nov 30, 2021
@github-actions
Copy link

github-actions bot commented Dec 1, 2021

Please check whether the issue should be labeled with 'affects-x.y' or 'fixes-x.y.z', and then remove 'needs-more-info' label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants