[MDEV-32208] ORDER BY unnecessary verbose Created: 2023-09-20 Updated: 2023-09-23 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | None |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major |
| Reporter: | Friedrich Spee von Langenfeld | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Description |
|
In theory, ORDER BY allows unqualified column names, if the column can be uniquely determined. In practice, this does not work for JOINs with equality conditions between columns.
This example should work, since the values of the column PVN are equal for both columns (t.PVN as well as s.PVN), therefore the sort ordering is equal. It does not work, because ORDER BY sees the columns t.PVN and s.PVN as different. My proposal: If an ORDER-BY-columns seems to be ambiguous (multiple ,,candidate columns" x.column, y.column, ...), check
If all these conditions are fulfilled, it is safe to use anyone of these candidate columns as sort column, such that an unnecessary qualification of the column name within the ORDER-BY-clause is not necessary. |