summaryrefslogtreecommitdiff
path: root/mysql-test/t/union.test
diff options
context:
space:
mode:
authorigor@olga.mysql.com <>2007-12-14 13:42:46 -0800
committerigor@olga.mysql.com <>2007-12-14 13:42:46 -0800
commitf25e30ebed447b3749ecea0efbb0c80a2e71b34f (patch)
treea4ca84ac2c8b4f8379b7c58993dccf27019214d4 /mysql-test/t/union.test
parent2627f775beb2e70a18b21894fcf69e76059fdcfd (diff)
downloadmariadb-git-f25e30ebed447b3749ecea0efbb0c80a2e71b34f.tar.gz
Fixed bug #27848.
In a union without braces, the order by at the end is applied to the overall union. It therefore should not interfere with the individual select parts of the union. Fixed by changing our parser rules appropriately.
Diffstat (limited to 'mysql-test/t/union.test')
-rw-r--r--mysql-test/t/union.test44
1 files changed, 44 insertions, 0 deletions
diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test
index 22f09466b1c..0277b01e21a 100644
--- a/mysql-test/t/union.test
+++ b/mysql-test/t/union.test
@@ -877,4 +877,48 @@ DROP TABLE t1;
select @var;
--error 1172
(select 2) union (select 1 into @var);
+
+#
+# Bug#27848: order-by of union clashes with rollup of select part
+#
+
+CREATE TABLE t1 (a int);
+INSERT INTO t1 VALUES (10), (20);
+CREATE TABLE t2 (b int);
+INSERT INTO t2 VALUES (10), (50), (50);
+
+SELECT a,1 FROM t1
+UNION
+SELECT b, COUNT(*) FROM t2 GROUP BY b WITH ROLLUP
+ORDER BY a;
+
+SELECT a,1 FROM t1
+UNION
+SELECT b, COUNT(*) FROM t2 GROUP BY b WITH ROLLUP
+ORDER BY a DESC;
+
+SELECT a,1 FROM t1
+UNION
+SELECT b, COUNT(*) FROM t2 GROUP BY b WITH ROLLUP
+ORDER BY a ASC LIMIT 3;
+
+SELECT a,1 FROM t1
+UNION ALL
+SELECT b, COUNT(*) FROM t2 GROUP BY b WITH ROLLUP
+ORDER BY a DESC;
+
+--error ER_WRONG_USAGE
+SELECT a,1 FROM t1
+UNION
+(SELECT b, COUNT(*) FROM t2 GROUP BY b WITH ROLLUP ORDER BY a);
+
+--error ER_WRONG_USAGE
+SELECT a,1 FROM t1
+UNION ALL
+SELECT b, COUNT(*) FROM t2 GROUP BY b WITH ROLLUP ORDER BY a
+UNION
+SELECT 1,1;
+
+DROP TABLE t1,t2;
+
--echo End of 5.0 tests