Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-20606

Union with parentheses and IN()

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Duplicate
    • 10.4.8, 10.4(EOL)
    • 10.4.9
    • Parser
    • None
    • linux (ubuntu 18.04 64-bit, mariadb 10.4.8-MariaDB-1:10.4.8)

    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        |
      +----+----------+
      

      Attachments

        Issue Links

          Activity

            People

              sanja Oleksandr Byelkin
              coleifer Charles Leifer
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.