-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
some querys that has DISTINCT
and ORDER BY
should be invalid
#4254
Labels
help wanted
Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.
type/compatibility
type/enhancement
The issue or PR belongs to an enhancement.
Comments
zz-jason
added
type/compatibility
type/enhancement
The issue or PR belongs to an enhancement.
todo
labels
Aug 20, 2017
Mysql version: Server version: 5.7.19 Homebrew |
This specific behavior depends on sql_mode.
|
zimulala
added
the
help wanted
Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.
label
Mar 20, 2018
Confirming that this issue is still present:
|
This is no longer the case, so I think we can close this issue: tidb> select distinct a, b from t order by c;
ERROR 3065 (HY000): Expression #1 of ORDER BY clause is not in SELECT list, references column 'test.t.c' which is not in SELECT list; this is incompatible with DISTINCT
tidb> select tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v5.2.1
Edition: Community
Git Commit Hash: cd8fb24c5f7ebd9d479ed228bb41848bd5e97445
Git Branch: heads/refs/tags/v5.2.1
UTC Build Time: 2021-09-08 02:32:56
GoVersion: go1.16.4
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
1 row in set (0.00 sec) However, the detection is not perfect. See: #29418 -- we can leave this new bug open as it is a different case. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
help wanted
Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.
type/compatibility
type/enhancement
The issue or PR belongs to an enhancement.
1. What did you do?
To order the result, duplicates must be eliminated first. But to do so, which row should we keep ? This choice influences the retained value of
c
, which in turn influences ordering and makes it arbitrary as well.In MySQL, a query that has
DISTINCT
andORDER BY
is rejected as invalid if anyORDER BY
expression does not satisfy at least one of these conditions:2. What did you expect to see?
3. What did you see instead?
4. What version of TiDB are you using (
tidb-server -V
)?The text was updated successfully, but these errors were encountered: