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

orderby clause ref priority doesn't take effect #45797

Closed
AilinKid opened this issue Aug 3, 2023 · 1 comment
Closed

orderby clause ref priority doesn't take effect #45797

AilinKid opened this issue Aug 3, 2023 · 1 comment
Assignees
Labels
affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. severity/minor sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@AilinKid
Copy link
Contributor

AilinKid commented Aug 3, 2023

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

CREATE TABLE `x` (
  `a` varchar(20) COLLATE utf8mb4_bin NOT NULL,
  `b` decimal(10,4) DEFAULT NULL,
  PRIMARY KEY (`a`),
  UNIQUE KEY `b` (`b`)
) COLLATE=utf8mb4_bin

mysql> select * from x;
+---+---------+
| a | b       |
+---+---------+
| i | -1.0000 |
| I |  1.0988 |
+---+---------+
2 rows in set (0.03 sec)

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

mysql

mysql> select a, char_length(b) from x order by lower(a), b;
+---+----------------+
| a | char_length(b) |
+---+----------------+
| i |              7 |
| I |              6 |
+---+----------------+
2 rows in set (0.02 sec)

mysql> select a, char_length(b) as b from x order by lower(a), b;
+---+------+
| a | b    |
+---+------+
| I |    6 |
| i |    7 |
+---+------+
2 rows in set (0.03 sec)

3. What did you see instead (Required)

tidb

tidb> select a, char_length(b)  from x order by lower(a), b;
+---+----------------+
| a | char_length(b) |
+---+----------------+
| i |              7 |
| I |              6 |
+---+----------------+
2 rows in set (0.00 sec)

tidb> select a, char_length(b)  as b from x order by lower(a), b;
+---+------+
| a | b    |
+---+------+
| i |    7 |
| I |    6 |
+---+------+
2 rows in set (0.00 sec)

4. What is your TiDB version? (Required)

git hash: 4220dfa

@AilinKid AilinKid added the type/bug The issue is confirmed as a bug. label Aug 3, 2023
@AilinKid
Copy link
Contributor Author

AilinKid commented Aug 3, 2023

@AilinKid AilinKid self-assigned this Aug 3, 2023
@AilinKid AilinKid closed this as completed Aug 3, 2023
@ti-chi-bot ti-chi-bot added affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. affects-6.1 This bug affects the 6.1.x(LTS) versions. labels Aug 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-6.1 This bug affects the 6.1.x(LTS) versions. affects-6.5 This bug affects the 6.5.x(LTS) versions. affects-7.1 This bug affects the 7.1.x(LTS) versions. severity/minor sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

2 participants