Bug #25734 union and parentheses
Submitted: 20 Jan 2007 17:34 Modified: 22 Jan 2007 17:35
Reporter: Nikolas Garofil
Status: Won't fix
Category:Server: Parser Severity:S2 (Serious)
Version:5.0.30-Debian_3-log OS:Linux (Debian)
Assigned to: Marc Alff Target Version:
Tags: parantheses, UNION, error, query, bfsm_2007_04_05
Triage: D4 (Minor)

[20 Jan 2007 17:34] Nikolas Garofil
Description:
Suppose 'foo' is a column of table 'bar'

Query's of the form "select foo from bar where foo in ((select foo from bar) union
(select foo from bar))" do not work. (ERROR 1064 (42000))

When I remove the innner parantheses from the first part of the union like this "select
foo from bar where foo in (select foo from bar union (select foo from bar))" then it
works

When I only keep everything between the outer parentheses like this "(select foo from
bar) union (select foo from bar)" then it also works

The error also happens in other querys that look a lot like my query, but this is the
shortest form i could found that would generate the error.

I know that the query is a strange and useless query because it is exactly the same as
"select distinct foo from bar" but it should work

How to repeat:
select foo from bar where foo in ((select foo from bar) union (select foo from bar));
[20 Jan 2007 19:05] Sveta Smirnova
Please do not submit the same bug more than once. An existing bug report already describes
this very problem. Even if you feel that your issue is somewhat different, the resolution
is likely
to be the same. Because of this, we hope you add your comments to the original bug
instead.

Thank you for your interest in MySQL.

Same cause as in the bug #21904, so I marked it as duplicate

Duplicates bug #21904
[22 Jan 2007 17:35] Marc Alff
Re-Opening the report.

The problem in Bug#21904 is different from the one found here.
- in Bug#21904, a IN ((subselect)) is parsed correctly, but executed
as a scalar subquery where it should be executed as a table subquery.
- in this report, the IN clause is not of the form IN ((subselect)),
but of the form IN(subselect), with a subselect that contains a join.

The parser fails to read the subselect properly (ERROR 1064), so the root
cause affecting this report is different from Bug#21904.

There is an issue with parsing subselects that starts with a parenthesis.
[5 Feb 2007 19:51] Marc Alff
See related bug#14654
[30 Mar 2007 18:23] Marc Alff
See related bug#21614
[30 Mar 2007 18:25] Konstantin Osipov
Bug#21614 "UNION in views" was marked a duplicate of this bug.
[3 Apr 2007 18:25] Marc Alff
See related Bug#4805
[4 Apr 2007 16:20] Damien Katz
I will be working to this bug soon.
[22 Sep 2008 21:59] Sveta Smirnova
Bug #39589 was marked as duplicate of this one.