[MDEV-10101] Wrong error message of SELECT 1 UNION (SELECT 1 FROM t1 GROUP BY 1 WITH ROLLUP) Created: 2016-05-23  Updated: 2016-06-01  Resolved: 2016-06-01

Status: Closed
Project: MariaDB Server
Component/s: Parser
Affects Version/s: 10.0, 10.1, 10.2
Fix Version/s: 10.2.1

Type: Bug Priority: Major
Reporter: Alexander Barkov Assignee: Alexander Barkov
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Blocks
blocks MDEV-8909 union parser cleanup Closed
Sprint: 10.2.1-5

 Description   

This script:

DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (10);
SELECT 1 UNION (SELECT 2 FROM t1 GROUP BY 1 WITH ROLLUP);

returns a wrong error message:

ERROR 1221 (HY000): Incorrect usage of CUBE/ROLLUP and ORDER BY

If I remove parentheses:

SELECT 1 UNION SELECT 2 FROM t1 GROUP BY 1 WITH ROLLUP;

it returns a result:

+------+
| 1    |
+------+
|    1 |
|    2 |
| NULL |
+------+

If I rewrite the query the other way around:

(SELECT 1 FROM t1 GROUP BY 1 WITH ROLLUP) UNION SELECT 2;

it returns a result:

+------+
| 1    |
+------+
|    1 |
| NULL |
|    2 |
+------+


Generated at Thu Feb 08 07:39:41 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.