Commit 28641640 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-10101 Wrong error message of SELECT 1 UNION (SELECT 1 FROM t1 GROUP BY 1 WITH ROLLUP)

parent caee832d
......@@ -930,17 +930,27 @@ ERROR HY000: Invalid use of group function
SELECT 1 AS a UNION (SELECT a FROM t1 GROUP BY a ORDER BY GROUP_CONCAT(a)) ORDER BY a LIMIT 1;
ERROR HY000: Invalid use of group function
DROP TABLE t1;
# UNION with a parethesized term with ROLLUP
# UNION with a parenthesized term with ROLLUP
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (10),(20),(30);
SELECT 1 AS a UNION (SELECT a FROM t1 GROUP BY a WITH ROLLUP);
ERROR HY000: Incorrect usage of CUBE/ROLLUP and ORDER BY
a
1
10
20
30
NULL
SELECT 1 AS a UNION (SELECT a FROM t1 GROUP BY a WITH ROLLUP) LIMIT 1;
ERROR HY000: Incorrect usage of CUBE/ROLLUP and ORDER BY
a
1
SELECT 1 AS a UNION (SELECT a FROM t1 GROUP BY a WITH ROLLUP) ORDER BY a LIMIT 1;
ERROR HY000: Incorrect usage of CUBE/ROLLUP and ORDER BY
a
NULL
SELECT 1 AS a UNION (SELECT a FROM t1 GROUP BY a WITH ROLLUP LIMIT 2);
ERROR HY000: Incorrect usage of CUBE/ROLLUP and ORDER BY
a
1
10
20
SELECT 1 AS a UNION (SELECT a FROM t1 GROUP BY a WITH ROLLUP ORDER BY a);
ERROR HY000: Incorrect usage of CUBE/ROLLUP and ORDER BY
SELECT 1 AS a UNION (SELECT a FROM t1 GROUP BY a WITH ROLLUP ORDER BY GROUP_CONCAT(a));
......@@ -1154,3 +1164,58 @@ ERROR HY000: Incorrect usage of CUBE/ROLLUP and ORDER BY
SELECT (SELECT GROUP_CONCAT(a ORDER BY a) FROM t1 GROUP BY a WITH ROLLUP ORDER BY a LIMIT 1) AS a FROM t1;
ERROR HY000: Incorrect usage of CUBE/ROLLUP and ORDER BY
DROP TABLE t1;
MDEV-10101 Wrong error message of SELECT 1 UNION (SELECT 1 FROM t1 GROUP BY 1 WITH ROLLUP)
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (10),(20),(30);
SELECT 1 AS a UNION (SELECT a FROM t1 GROUP BY a WITH ROLLUP);
a
1
10
20
30
NULL
(SELECT a FROM t1 GROUP BY a WITH ROLLUP) UNION SELECT 1;
a
10
20
30
NULL
1
SELECT a FROM t1 GROUP BY a WITH ROLLUP UNION SELECT 1;
a
10
20
30
NULL
1
SELECT 1 AS a UNION (SELECT a FROM t1 GROUP BY a WITH ROLLUP) LIMIT 1;
a
1
(SELECT a FROM t1 GROUP BY a WITH ROLLUP) UNION SELECT 1 LIMIT 1;
a
10
SELECT a FROM t1 GROUP BY a WITH ROLLUP UNION SELECT 1 LIMIT 1;
a
10
SELECT 1 AS a UNION (SELECT a FROM t1 GROUP BY a WITH ROLLUP) ORDER BY a LIMIT 1;
a
NULL
(SELECT a FROM t1 GROUP BY a WITH ROLLUP) UNION SELECT 1 ORDER BY a LIMIT 1;
a
NULL
SELECT a FROM t1 GROUP BY a WITH ROLLUP UNION SELECT 1 ORDER BY a LIMIT 1;
a
NULL
SELECT 1 AS a UNION (SELECT a FROM t1 GROUP BY a WITH ROLLUP LIMIT 2);
a
1
10
20
(SELECT a FROM t1 GROUP BY a WITH ROLLUP LIMIT 2) UNION SELECT 1;
a
10
20
1
DROP TABLE t1;
......@@ -1075,18 +1075,16 @@ SELECT 1 AS a UNION (SELECT a FROM t1 GROUP BY a ORDER BY GROUP_CONCAT(a)) ORDER
SELECT 1 AS a UNION (SELECT a FROM t1 GROUP BY a ORDER BY GROUP_CONCAT(a)) ORDER BY a LIMIT 1;
DROP TABLE t1;
--echo # UNION with a parethesized term with ROLLUP
--echo # UNION with a parenthesized term with ROLLUP
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (10),(20),(30);
--error ER_WRONG_USAGE
SELECT 1 AS a UNION (SELECT a FROM t1 GROUP BY a WITH ROLLUP);
--error ER_WRONG_USAGE
SELECT 1 AS a UNION (SELECT a FROM t1 GROUP BY a WITH ROLLUP) LIMIT 1;
--error ER_WRONG_USAGE
SELECT 1 AS a UNION (SELECT a FROM t1 GROUP BY a WITH ROLLUP) ORDER BY a LIMIT 1;
--error ER_WRONG_USAGE
SELECT 1 AS a UNION (SELECT a FROM t1 GROUP BY a WITH ROLLUP LIMIT 2);
--error ER_WRONG_USAGE
SELECT 1 AS a UNION (SELECT a FROM t1 GROUP BY a WITH ROLLUP ORDER BY a);
--error ER_WRONG_USAGE
......@@ -1225,3 +1223,27 @@ SELECT (SELECT * FROM t1 GROUP BY a WITH ROLLUP ORDER BY GROUP_CONCAT(a)) FROM t
SELECT (SELECT GROUP_CONCAT(a ORDER BY a) FROM t1 GROUP BY a WITH ROLLUP ORDER BY a LIMIT 1) AS a FROM t1;
DROP TABLE t1;
--echo
--echo MDEV-10101 Wrong error message of SELECT 1 UNION (SELECT 1 FROM t1 GROUP BY 1 WITH ROLLUP)
--echo
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (10),(20),(30);
SELECT 1 AS a UNION (SELECT a FROM t1 GROUP BY a WITH ROLLUP);
(SELECT a FROM t1 GROUP BY a WITH ROLLUP) UNION SELECT 1;
SELECT a FROM t1 GROUP BY a WITH ROLLUP UNION SELECT 1;
SELECT 1 AS a UNION (SELECT a FROM t1 GROUP BY a WITH ROLLUP) LIMIT 1;
(SELECT a FROM t1 GROUP BY a WITH ROLLUP) UNION SELECT 1 LIMIT 1;
SELECT a FROM t1 GROUP BY a WITH ROLLUP UNION SELECT 1 LIMIT 1;
SELECT 1 AS a UNION (SELECT a FROM t1 GROUP BY a WITH ROLLUP) ORDER BY a LIMIT 1;
(SELECT a FROM t1 GROUP BY a WITH ROLLUP) UNION SELECT 1 ORDER BY a LIMIT 1;
SELECT a FROM t1 GROUP BY a WITH ROLLUP UNION SELECT 1 ORDER BY a LIMIT 1;
SELECT 1 AS a UNION (SELECT a FROM t1 GROUP BY a WITH ROLLUP LIMIT 2);
(SELECT a FROM t1 GROUP BY a WITH ROLLUP LIMIT 2) UNION SELECT 1;
DROP TABLE t1;
......@@ -737,13 +737,6 @@ bool setup_select_in_parentheses(LEX *lex)
my_parse_error(lex->thd, ER_SYNTAX_ERROR);
return TRUE;
}
if (sel->linkage == UNION_TYPE &&
sel->olap != UNSPECIFIED_OLAP_TYPE &&
sel->master_unit()->fake_select_lex)
{
my_error(ER_WRONG_USAGE, MYF(0), "CUBE/ROLLUP", "ORDER BY");
return TRUE;
}
return FALSE;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment