[MDEV-10120] Wrong result of UNION .. ORDER BY GROUP_CONCAT() Created: 2016-05-25 Updated: 2020-07-09 Resolved: 2020-07-09 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data Manipulation - Subquery, Optimizer |
| Affects Version/s: | 5.5, 10.0, 10.1, 10.2, 10.3, 10.4, 10.5 |
| Fix Version/s: | 10.2.33, 10.3.24, 10.4.14, 10.5.5, 10.6.0 |
| Type: | Bug | Priority: | Major |
| Reporter: | Alexander Barkov | Assignee: | Varun Gupta (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | upstream-fixed | ||
| Issue Links: |
|
||||||||
| Description |
|
returns this result:
This is wrong. The right part of the union alone:
returns
The result of a UNION can't return less rows than UNION parts alone. The same problem is repeatable with other aggregate functions:
|
| Comments |
| Comment by Alexander Barkov [ 2016-05-25 ] | ||||||||||||||||||
|
This problem is not repeatable in MySQL-5.7, which returns an error:
Related MySQL bugs: | ||||||||||||||||||
| Comment by Varun Gupta (Inactive) [ 2020-07-01 ] | ||||||||||||||||||
|
Adding brackets at different places gives the varying results, maybe this is what is happening. The query is getting executed as the first one. | ||||||||||||||||||
| Comment by Varun Gupta (Inactive) [ 2020-07-02 ] | ||||||||||||||||||
|
From the knowledge base https://mariadb.com/kb/en/union/, Also mysql docs say | ||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2020-07-02 ] | ||||||||||||||||||
|
So it is clear that GROUP BY is local to the last SELECT in the union. | ||||||||||||||||||
| Comment by Varun Gupta (Inactive) [ 2020-07-06 ] | ||||||||||||||||||
|
Patch | ||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2020-07-09 ] | ||||||||||||||||||
|
OK to push |