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

OUTER JOIN of NATURAL JOINs is not supported

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 5.5(EOL), 10.0(EOL), 10.1(EOL), 10.2(EOL)
    • 10.2(EOL)
    • Parser
    • None
    • 10.2.14

    Description

      This query:

      SELECT * FROM
      t1 NATURAL JOIN t2
          LEFT JOIN
      t3 NATURAL JOIN t4
          USING (a);
      

      produces an error:

      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 'USING (a)' at line 4
      

      This is a wrong behavior. It's a valid query according to the standard.
      Oracle and PostgreSQL support this.

      The problem here is that the USING clause is related to the LEFT JOIN operation, while MariaDB tries to apply it to the second NATURAL JOIN.

      According to the Standard, NATURAL and CROSS joins have higher precedence over OUTER and INNER joins.

      So the above query should mean exactly the same with:

      SELECT * FROM
      (t1 NATURAL JOIN t2)
          LEFT JOIN
      (t3 NATURAL JOIN t4)
          USING (a);
      

      which works fine and does not produce syntax errors.

      Attachments

        Activity

          People

            psergei Sergei Petrunia
            bar Alexander Barkov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

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