Bug #105163 | Incorrect ordering by an expression which includes output column | ||
---|---|---|---|
Submitted: | 7 Oct 2021 8:46 | Modified: | 7 Oct 2021 12:56 |
Reporter: | Владислав Сокол | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server | Severity: | S3 (Non-critical) |
Version: | 8.0.26 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[7 Oct 2021 8:46]
Владислав Сокол
[7 Oct 2021 13:13]
MySQL Verification Team
HI Mr. Sokol, Thank you for your bug report. However, it is not a bug. The aggregated SELECT statements do not allow expressions in the ORDER BY clause. This is mentioned in our Reference Manual: " Columns selected for output can be referred to in ORDER BY and GROUP BY clauses using column names, column aliases, or column positions. Column positions are integers and begin with 1. " Not a bug.
[8 Oct 2021 8:53]
Øystein Grøvlen
If expressions were not allowed, I would think the query should cause a syntax error. However, according to the manual, an ORDER BY expression can have the following syntax: [ORDER BY {col_name | expr | position} [ASC | DESC], ... [WITH ROLLUP]] So it seems expressions are allowed in ORDER BY statements. The cited statement just says how columns may be referred to. If 1 is to be interpreted as column position, even in expressions, it seems to output order is still wrong.