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

Subquery syntax differences between 10.1/10.4 and 10.2/10.3

    XMLWordPrintable

Details

    Description

      With 10.2 and 10.3, a subquery can't refer to columns of the outer query,
      with 10.0 and 10.4 the same query works fine.

      DROP TABLE IF EXISTS t1;
      DROP TABLE IF EXISTS t2;
       
      CREATE TABLE t1(id1 INT PRIMARY KEY);
      CREATE TABLE t2(id2 INT PRIMARY KEY);
       
      INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
      INSERT INTO t2 VALUES (1),(3),(5);
       
      SELECT (SELECT id1 WHERE id1 IN (SELECT id2 FROM t2)) AS result FROM t1;
      

      Expected result, as seen with MariaDB 10.1.x and 10.4.7:

      +--------+
      | result |
      +--------+
      |      1 |
      |   NULL |
      |      3 |
      |   NULL |
      |      5 |
      +--------+
      

      Actual result with 10.2 and 10.3 GA versions:

      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 'WHERE id1 IN (SELECT id2 FROM t2)) AS result FROM t1' at line 1
      

      Attachments

        Activity

          People

            sanja Oleksandr Byelkin
            hholzgra Hartmut Holzgraefe
            Votes:
            0 Vote for this issue
            Watchers:
            6 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.