summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <gkodinov/kgeorge@magare.gmz>2007-12-18 11:07:08 +0200
committerunknown <gkodinov/kgeorge@magare.gmz>2007-12-18 11:07:08 +0200
commit82e026c1462dc2b5971bb83efffa5a82492dc1e7 (patch)
treecb036e8ee3dacc88a815cab2435a05809623ee7b
parent8aac47e2ccf70471c0296a32fa6aa433081c6984 (diff)
parent55d284d424c954888536f615731a61d039d80ac1 (diff)
downloadmariadb-git-82e026c1462dc2b5971bb83efffa5a82492dc1e7.tar.gz
Merge magare.gmz:/home/kgeorge/mysql/autopush/B19390-5.0-opt
into magare.gmz:/home/kgeorge/mysql/work/B19390-5.1-opt client/mysql.cc: Auto merged client/mysqltest.c: Auto merged mysql-test/r/func_gconcat.result: Auto merged mysql-test/suite/rpl/r/rpl_trigger.result: Auto merged mysql-test/suite/rpl/t/rpl_trigger.test: Auto merged mysql-test/t/func_gconcat.test: Auto merged sql/item_sum.cc: Auto merged sql/item_timefunc.cc: Auto merged sql/log.cc: Auto merged sql/set_var.cc: Auto merged sql/sp.cc: Auto merged sql/sql_class.cc: Auto merged sql/sql_class.h: Auto merged sql/unireg.cc: Auto merged mysql-test/r/union.result: Merged bug 27848 to 5.1-opt mysql-test/t/union.test: Merged bug 27848 to 5.1-opt sql/sql_yacc.yy: Merged bug 27848 to 5.1-opt
-rw-r--r--mysql-test/r/union.result51
-rw-r--r--mysql-test/suite/rpl/r/rpl_trigger.result12
-rw-r--r--mysql-test/suite/rpl/t/rpl_trigger.test12
-rw-r--r--mysql-test/t/union.test44
-rw-r--r--sql/sql_yacc.yy11
5 files changed, 121 insertions, 9 deletions
diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result
index 6fc630ec33c..a8f538b6cc7 100644
--- a/mysql-test/r/union.result
+++ b/mysql-test/r/union.result
@@ -1445,4 +1445,55 @@ select @var;
1
(select 2) union (select 1 into @var);
ERROR 42000: Result consisted of more than one row
+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;
+a 1
+NULL 3
+10 1
+20 1
+50 2
+SELECT a,1 FROM t1
+UNION
+SELECT b, COUNT(*) FROM t2 GROUP BY b WITH ROLLUP
+ORDER BY a DESC;
+a 1
+50 2
+20 1
+10 1
+NULL 3
+SELECT a,1 FROM t1
+UNION
+SELECT b, COUNT(*) FROM t2 GROUP BY b WITH ROLLUP
+ORDER BY a ASC LIMIT 3;
+a 1
+NULL 3
+10 1
+20 1
+SELECT a,1 FROM t1
+UNION ALL
+SELECT b, COUNT(*) FROM t2 GROUP BY b WITH ROLLUP
+ORDER BY a DESC;
+a 1
+50 2
+20 1
+10 1
+10 1
+NULL 3
+SELECT a,1 FROM t1
+UNION
+(SELECT b, COUNT(*) FROM t2 GROUP BY b WITH ROLLUP ORDER BY a);
+ERROR HY000: Incorrect usage of CUBE/ROLLUP and ORDER BY
+SELECT a,1 FROM t1
+UNION ALL
+SELECT b, COUNT(*) FROM t2 GROUP BY b WITH ROLLUP ORDER BY a
+UNION
+SELECT 1,1;
+ERROR HY000: Incorrect usage of UNION and ORDER BY
+DROP TABLE t1,t2;
End of 5.0 tests
diff --git a/mysql-test/suite/rpl/r/rpl_trigger.result b/mysql-test/suite/rpl/r/rpl_trigger.result
index b4ce3ee1d36..68c82ed037f 100644
--- a/mysql-test/suite/rpl/r/rpl_trigger.result
+++ b/mysql-test/suite/rpl/r/rpl_trigger.result
@@ -91,21 +91,25 @@ select a=b && a=c from t1;
a=b && a=c
1
SELECT routine_name, definer
-FROM information_schema.routines;
+FROM information_schema.routines
+WHERE routine_name = 'bug12480';
routine_name definer
bug12480 root@localhost
SELECT trigger_name, definer
-FROM information_schema.triggers;
+FROM information_schema.triggers
+WHERE trigger_name = 't1_first';
trigger_name definer
t1_first root@localhost
--- On slave --
SELECT routine_name, definer
-FROM information_schema.routines;
+FROM information_schema.routines
+WHERE routine_name = 'bug12480';
routine_name definer
bug12480 root@localhost
SELECT trigger_name, definer
-FROM information_schema.triggers;
+FROM information_schema.triggers
+WHERE trigger_name = 't1_first';
trigger_name definer
t1_first root@localhost
select a=b && a=c from t1;
diff --git a/mysql-test/suite/rpl/t/rpl_trigger.test b/mysql-test/suite/rpl/t/rpl_trigger.test
index 4a496ea4923..911110d17dc 100644
--- a/mysql-test/suite/rpl/t/rpl_trigger.test
+++ b/mysql-test/suite/rpl/t/rpl_trigger.test
@@ -101,10 +101,12 @@ let $time=`select a from t1`;
# - dump definers on the slave;
SELECT routine_name, definer
-FROM information_schema.routines;
+FROM information_schema.routines
+WHERE routine_name = 'bug12480';
SELECT trigger_name, definer
-FROM information_schema.triggers;
+FROM information_schema.triggers
+WHERE trigger_name = 't1_first';
save_master_pos;
connection slave;
@@ -119,10 +121,12 @@ select "--- On slave --" as "";
# item.
SELECT routine_name, definer
-FROM information_schema.routines;
+FROM information_schema.routines
+WHERE routine_name = 'bug12480';
SELECT trigger_name, definer
-FROM information_schema.triggers;
+FROM information_schema.triggers
+WHERE trigger_name = 't1_first';
select a=b && a=c from t1;
--disable_query_log
diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test
index a57ab469ac2..0f8ba1aeae0 100644
--- a/mysql-test/t/union.test
+++ b/mysql-test/t/union.test
@@ -922,4 +922,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
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index b4d8bb2dfb8..6d2e4ea9a59 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -6151,6 +6151,14 @@ select_paren:
my_parse_error(ER(ER_SYNTAX_ERROR));
MYSQL_YYABORT;
}
+ 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");
+ MYSQL_YYABORT;
+ }
/* select in braces, can't contain global parameters */
if (sel->master_unit()->fake_select_lex)
sel->master_unit()->global_parameters=
@@ -8039,7 +8047,8 @@ order_clause:
SELECT_LEX *sel= lex->current_select;
SELECT_LEX_UNIT *unit= sel-> master_unit();
if (sel->linkage != GLOBAL_OPTIONS_TYPE &&
- sel->olap != UNSPECIFIED_OLAP_TYPE)
+ sel->olap != UNSPECIFIED_OLAP_TYPE &&
+ (sel->linkage != UNION_TYPE || sel->braces))
{
my_error(ER_WRONG_USAGE, MYF(0),
"CUBE/ROLLUP", "ORDER BY");