[MDEV-25133] sql mode ONLY_FULL_GROUP_BY lets query fail when grouping expression contains constant Created: 2021-03-14 Updated: 2021-04-05 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | 10.5.9 |
| Fix Version/s: | 10.5 |
| Type: | Bug | Priority: | Major |
| Reporter: | Remy Fox | Assignee: | Igor Babaev |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | only_full_group_by | ||
| Issue Links: |
|
||||||||
| Description |
|
There is a rule for aggregated queries which says that SELECT expressions can only reference columns that were used to group by or were aggregated on. Sql mode ONLY_FULL_GROUP_BY enforces this rule. When this mode is activated there will be an error for queries that reference columns in SELECT expressions that were not used to group by. I found a false positive though:
This is a valid query
This query has an additional constant. It is also valid:
Clients should not need to write a position, though.These queries fail, even though the rule is still adhered to:
And this query also fails:
|
| Comments |
| Comment by Alice Sherepa [ 2021-03-15 ] | ||||||||||||||||||||
|
The first case might be considered as a bug, as GROUP BY 1 or if we name this column, then query works;
|