Bug #81342 | Using ONLY_FULL_GROUP_BY rejects statements in MySQL 5.7 but not in MySQL 5.6 | ||
---|---|---|---|
Submitted: | 6 May 2016 22:22 | Modified: | 26 Jun 2018 2:40 |
Reporter: | monty solomon | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: Documentation | Severity: | S3 (Non-critical) |
Version: | 5.7.11 | OS: | CentOS |
Assigned to: | CPU Architecture: | Any |
[6 May 2016 22:22]
monty solomon
[9 May 2016 14:37]
MySQL Verification Team
HI Monty, This is not related to GROUP BY, as you do not have any, but at the combo of DISTINCT and ORDER BY. However, this is still a bug , but in documentation. Verified as documentation bug.
[9 May 2016 17:41]
monty solomon
FYI, I see this paragraph in the blog post about improvements in only_full_group_by. There was one last fix done as part of this Worklog. That is having to do with some rare non-grouped queries of the form SELECT DISTINCT ... ORDER BY also being non-deterministic, but this post is already long so I’ll discuss that in a subsequent post. Stay tuned! http://mysqlserverteam.com/mysql-5-7-only_full_group_by-improved-recognizing-functional-de...
[9 May 2016 17:45]
monty solomon
That paragraph referred to "WL#2489: Better ONLY_FULL_GROUP_BY mode" http://dev.mysql.com/worklog/task/?id=2489 Implement F-6: make it apply some restrictions to DISTINCT + ORDER BY ===================================================================== in a query with DISTINCT and ORDER BY, we can get random order: select distinct a from t1 order by b; during execution, depending on the query plan, we may apply DISTINCT before ORDER BY; when we apply DISTINCT we may pick a value of 'b' in the group of rows which have the same value of 'a'. That gives random order of the final result. This was filed as: Bug #13581713 ONLY_FULL_GROUP_BY DOES NOT BLOCK "SELECT DISTINCT A ORDER BY B". We see that this is a problem which is similar in nature to what only_full_group_by wants to fight. Thus, we should make only_full_group_by add restrictions on DISTINCT + ORDER BY. The proper restrictions are described in the standard: if a query has ORDER BY, and one expression in ORDER BY is not identical to some expression in the SELECT list, and involves columns of tables of the FROM clause, then the query should not have DISTINCT. This worklog will fix Bug #13581713 .
[28 Nov 2016 9:12]
MySQL Verification Team
http://bugs.mysql.com/bug.php?id=83978 marked as duplicate of this one.
[26 Jun 2018 2:40]
Paul DuBois
Posted by developer: Conditions for rejection of DISTINCT + ORDER BY queries when ONLY_FULL_GROUP_BY is enabled are given at: https://dev.mysql.com/doc/refman/8.0/en/group-by-handling.html