diff options
author | Magne Mahre <magne.mahre@oracle.com> | 2011-01-10 13:43:12 +0100 |
---|---|---|
committer | Magne Mahre <magne.mahre@oracle.com> | 2011-01-10 13:43:12 +0100 |
commit | 90650edf697d498d0969f4bd9b81301ffc633dfa (patch) | |
tree | b14518869f4fdf7e6c6d3d43b1ab29117bbdc74b /mysql-test/t/union.test | |
parent | 1b64516756174c5de34ad77e54e3ecf164863ec4 (diff) | |
download | mariadb-git-90650edf697d498d0969f4bd9b81301ffc633dfa.tar.gz |
Bug#58970 Problem Subquery (without referencing a table)
and Order By
When having a UNION statement in a subquery, with no
referenced tables (or only a reference to the virtual
table 'dual'), the UNION did not allow an ORDER BY clause.
i.e:
SELECT(SELECT 1 AS a UNION
SELECT 0 AS a
ORDER BY a) AS b or
SELECT(SELECT 1 AS a FROM dual UNION
SELECT 0 as a
ORDER BY a) AS b
In addition, an ORDER BY / LIMIT clause was not accepted
in subqueries even for single SELECT statements with no
referenced tables (or with 'dual' as table reference)
i.e:
SELECT(SELECT 1 AS a ORDER BY a) AS b or
SELECT(SELECT 1 AS a FROM dual ORDER BY a) AS b
The fix was to allow an optional ORDER BY/LIMIT clause to
the grammar for these cases.
See also: Bug#57986
Diffstat (limited to 'mysql-test/t/union.test')
-rw-r--r-- | mysql-test/t/union.test | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index 694f1bab15c..c6599517e90 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -1171,3 +1171,16 @@ SELECT c1, c2 FROM ( ) AS res; DROP TABLE t1, t2; + +--echo # +--echo # Bug #58970 Problem Subquery (without referencing a table) +--echo # and Order By +--echo # + +SELECT(SELECT 0 AS a UNION SELECT 1 AS a ORDER BY a ASC LIMIT 1) AS dev; +SELECT(SELECT 0 AS a UNION SELECT 1 AS a ORDER BY a DESC LIMIT 1) AS dev; +SELECT(SELECT 0 AS a FROM dual UNION SELECT 1 AS a FROM dual ORDER BY a ASC LIMIT 1) AS dev; +SELECT(SELECT 0 AS a FROM dual UNION SELECT 1 AS a FROM dual ORDER BY a DESC LIMIT 1) AS dev; +SELECT(SELECT 1 AS a ORDER BY a) AS dev; +SELECT(SELECT 1 AS a LIMIT 1) AS dev; +SELECT(SELECT 1 AS a FROM dual ORDER BY a DESC LIMIT 1) AS dev; |