From 737c3025e9ed55855ee66806ad14e9e7e7852fa7 Mon Sep 17 00:00:00 2001 From: Varun Gupta Date: Thu, 9 Jul 2020 14:01:06 +0530 Subject: MDEV-10120: Wrong result of UNION .. ORDER BY GROUP_CONCAT() Reject queries that have aggregate functions with UNION as these are not allowed by standard. --- mysql-test/t/parser.test | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'mysql-test/t/parser.test') diff --git a/mysql-test/t/parser.test b/mysql-test/t/parser.test index 5faaca00ea8..7e11a71c500 100644 --- a/mysql-test/t/parser.test +++ b/mysql-test/t/parser.test @@ -1090,7 +1090,9 @@ CREATE TABLE t1 AS SELECT 1 LIMIT 1 UNION SELECT 2; --echo # For now, we're testing the parser. CREATE TABLE t1 (a INT); INSERT INTO t1 VALUES (10),(20),(30); +--error ER_AGGREGATE_ORDER_FOR_UNION SELECT 1 AS a UNION SELECT a FROM t1 GROUP BY a ORDER BY GROUP_CONCAT(a); +--error ER_AGGREGATE_ORDER_FOR_UNION SELECT 1 AS a UNION SELECT a FROM t1 GROUP BY a ORDER BY GROUP_CONCAT(a ORDER BY a); DROP TABLE t1; @@ -1131,8 +1133,11 @@ DROP TABLE t1; CREATE TABLE t1 (a INT); INSERT INTO t1 VALUES (10),(20),(30); +--error ER_AGGREGATE_ORDER_FOR_UNION SELECT 1 AS a UNION SELECT a FROM t1 GROUP BY a WITH ROLLUP ORDER BY GROUP_CONCAT(a); +--error ER_AGGREGATE_ORDER_FOR_UNION SELECT 1 AS a UNION SELECT a FROM t1 GROUP BY a WITH ROLLUP ORDER BY GROUP_CONCAT(a ORDER BY a); +--error ER_AGGREGATE_ORDER_FOR_UNION SELECT 1 AS a UNION SELECT a FROM t1 GROUP BY a WITH ROLLUP ORDER BY GROUP_CONCAT(a ORDER BY a) LIMIT 1; DROP TABLE t1; -- cgit v1.2.1