diff options
author | unknown <gkodinov/kgeorge@macbook.gmz> | 2006-08-31 18:00:25 +0300 |
---|---|---|
committer | unknown <gkodinov/kgeorge@macbook.gmz> | 2006-08-31 18:00:25 +0300 |
commit | c9bba13aee4132b661499be71dc9e0baad2fc485 (patch) | |
tree | 967a823d37eab09b1a75c2d578fda11db4db98f2 /mysql-test/t/subselect.test | |
parent | 1cbebc6e18e22d10b4be12634f5c6d2ed72cffca (diff) | |
download | mariadb-git-c9bba13aee4132b661499be71dc9e0baad2fc485.tar.gz |
Bug#14654 : Cannot select from the same table twice within a UNION statement
Made the parser to support parenthesis around UNION branches.
This is done by amending the rules of the parser so it generates the correct
structure.
Currently it supports arbitrary subquery/join/parenthesis operations in the
EXISTS clause.
In the IN/scalar subquery case it will allow adding nested parenthesis only
if there is an UNION clause after the parenthesis. Otherwise it will just
treat the multiple nested parenthesis as a scalar expression.
It adds extra lex level for ((SELECT ...) UNION ...) to accommodate for the
UNION clause.
mysql-test/r/subselect.result:
Bug#14654 : Cannot select from the same table twice within a UNION statement
- test cases
mysql-test/t/subselect.test:
Bug#14654 : Cannot select from the same table twice within a UNION statement
- test cases
sql/sql_yacc.yy:
Bug#14654 : Cannot select from the same table twice within a UNION statement
- shuffle around the rules for the parenthesis in subselect
Diffstat (limited to 'mysql-test/t/subselect.test')
-rw-r--r-- | mysql-test/t/subselect.test | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index c9ed62f0e54..a47221dbd02 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -2257,3 +2257,29 @@ SELECT * FROM t1,t2 ORDER BY t1.t DESC LIMIT 1); DROP TABLE t1, t2; + +# +# Bug#14654 : Cannot select from the same table twice within a UNION +# statement +# +CREATE TABLE t1 (i INT); + +(SELECT i FROM t1) UNION (SELECT i FROM t1); +SELECT sql_no_cache * FROM t1 WHERE NOT EXISTS + ( + (SELECT i FROM t1) UNION + (SELECT i FROM t1) + ); + +SELECT * FROM t1 +WHERE NOT EXISTS (((SELECT i FROM t1) UNION (SELECT i FROM t1))); + +#TODO:not supported +--error 1064 +explain select ((select t11.i from t1 t11) union (select t12.i from t1 t12)) + from t1; +#supported +explain select * from t1 where not exists + ((select t11.i from t1 t11) union (select t12.i from t1 t12)); + +DROP TABLE t1; |