[MDEV-20606] Union with parentheses and IN() Created: 2019-09-17  Updated: 2019-10-11  Resolved: 2019-10-11

Status: Closed
Project: MariaDB Server
Component/s: Parser
Affects Version/s: 10.4.8, 10.4
Fix Version/s: 10.4.9

Type: Bug Priority: Major
Reporter: Charles Leifer Assignee: Oleksandr Byelkin
Resolution: Duplicate Votes: 1
Labels: None
Environment:

linux (ubuntu 18.04 64-bit, mariadb 10.4.8-MariaDB-1:10.4.8)


Issue Links:
Relates
relates to MDEV-11953 support of brackets (parentheses) in ... Closed

 Description   

Although issue is closed and marked as resolved for 10.4, I am experiencing a very similar bug using mariadb 10.4.8.

Union with parentheses: https://jira.mariadb.org/browse/MDEV-11953

MySQL bug, recently fixed for 8.0: https://bugs.mysql.com/bug.php?id=25734

To replicate:

create table `users` (`id` integer not null primary key auto_increment, `username` text not null);
insert into `users` (`username`) values ('a'), ('b'), ('c');
 
select * from `users` where (`id` IN (
    (select `id` from `users` where `username` = 'a') 
    UNION 
    (select `id` from `users` where `username` = 'c')));
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UNION (select `id` from `users` where `username` = 'c')))' at line 1

Removing the parentheses around the left-hand side of the compound query "fixes" it:

select * from `users` where (`id` IN (
    select `id` from `users` where `username` = 'a' 
    UNION 
    (select `id` from `users` where `username` = 'c')));
 
+----+----------+
| id | username |
+----+----------+
|  1 | a        |
|  3 | c        |
+----+----------+



 Comments   
Comment by Oleksandr Byelkin [ 2019-10-11 ]

It is probably fixed by Igor's patch already (I cant it reproduce any more)

Generated at Thu Feb 08 09:00:47 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.