Bug #2435 union with braces do not supported
Submitted: 17 Jan 2004 5:26 Modified: 11 Mar 2005 17:11
Reporter: Oleksandr Byelkin Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.1 OS:Any (all)
Assigned to: Antony Curtis CPU Architecture:Any

[17 Jan 2004 5:26] Oleksandr Byelkin
Description:
union with braces do not supported, like 
select * from ((select * from t1 limit 1) union (select * from t1 limit 1)) a; 
cause error: query 'select * from (select * from t1 limit 1) union (select * 
from t1 limit 1) a' failed: 1247: Every derived table must have it's own alias 

How to repeat:
CREATE TABLE t1 (a int not null, b char (10) not null); 
insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c'); 
select * from ((select * from t1 limit 1) union (select * from t1 limit 1)) a;
[17 Jan 2004 11:38] MySQL Verification Team
This is a known problem with current parser generator (bison).

There is already one record on the same issue in this database.
[16 Nov 2004 19:44] Jason Carter
Please fix this bug.  It is hindering a mission-criticle function of my application.
[23 Nov 2004 12:57] Sergei Golubchik
Antony, could you check whether there's an easy way to fix the grammar ?
[26 Nov 2004 16:34] Arnim Rupp
hello,

we have a similar problem, the following query works in oracle 9 but brings the same error as above in mysql-standard-4.1.7-sun-solaris2.8-sparc-64bit:

SELECT tag t, c, l
FROM accessrule
LEFT JOIN
        (SELECT tag as t, SUM(count) AS c, MAX(last) AS l
        FROM connection WHERE fw='fw7'
        GROUP BY tag
        )
ON tag=t
WHERE rulebase='fw7a'
ORDER BY l DESC
[22 Dec 2004 11:00] Ingo Strüwing
I take the review with permission by Sergei. However, a second reviewer is required.
[28 Dec 2004 11:42] Ingo Strüwing
Does the fix solve the additional problem mentioned by arnim.rupp@lhsystems.com?
[25 Jan 2005 4:18] Sergey Petrunya
See also BUG#7360
[28 Jan 2005 11:32] Sergey Petrunya
Reviewed by Ingo, he's ok with cset mentioned.
[4 Feb 2005 17:54] Antony Curtis
New changeset committed which will allow more parentheses in union components.
[14 Feb 2005 14:47] Antony Curtis
Patch applied to 4.1 repository, 
ChangeSet@1.2183, 2005-02-13 22:35:52+00:00

Permits subsequent union elements to be in multiple parentheses. Initial select statement can not be in parentheses.
[11 Mar 2005 17:11] Paul DuBois
Noted in 4.1.11 changelog.