mirror of
https://github.com/MariaDB/server.git
synced 2025-01-19 21:42:35 +01:00
Merge olga.mysql.com:/home/igor/mysql-5.0-opt
into olga.mysql.com:/home/igor/dev-opt/mysql-5.0-opt-bug27848
This commit is contained in:
commit
43582593c3
3 changed files with 105 additions and 1 deletions
|
@ -1389,4 +1389,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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -4211,6 +4211,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=
|
||||
|
@ -6165,7 +6173,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");
|
||||
|
|
Loading…
Reference in a new issue