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

Unexpected Error Due to Alias Usage in MariaDB JOIN Subquery

    XMLWordPrintable

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Major
    • Resolution: Unresolved
    • 11.4.2, 10.5, 10.6, 10.11, 11.2, 11.4
    • 10.5, 10.6, 10.11, 11.2, 11.4
    • Optimizer
    • None
    • ubuntu 20.04

    Description

      setup database

       
      DROP TABLE IF EXISTS t0;
      DROP TABLE IF EXISTS t1;
       
      CREATE TABLE t0 (
      wkey INTEGER
      );
       
      CREATE TABLE t1 (
      pkey INTEGER PRIMARY KEY,
      c1 INTEGER
      );
       
      INSERT INTO t1 VALUES(2,3);
      INSERT INTO t0 VALUES(1);
          
      

      In mariadb he returns an error. But it doesn't seem to return an error.

      --mariadb
      SELECT *
      FROM t0 
      WHERE EXISTS (
        SELECT
          *
        FROM
          (t1 AS ref_1
            JOIN (
                SELECT
                  t0.wkey AS c1
                FROM
                  t0 AS ref_4
            ) AS subq_0
          ON true ));
       
       
         ERROR 1054 (42S22): Unknown column 't0.wkey' in 'field list'
       
      
      

      And in mysql it does not return error.

      --mysql
      SELECT *
      FROM t0 
      WHERE EXISTS (
        SELECT
          *
        FROM
          (t1 AS ref_1
            JOIN (
                SELECT
                  t0.wkey AS c1
                FROM
                  t0 AS ref_4
            ) AS subq_0
          ON true ));
       
      +------+
      | wkey |
      +------+
      |    1 |
      +------+
      1 row in set (0.00 sec)
       
      
      

      I found that after removing AS ref_4 , error is not returned in mariadb. It seems that there is a problem with this as processing.

      --mariadb
      SELECT *
      FROM t0 
      WHERE EXISTS (
        SELECT
          *
        FROM
          (t1 AS ref_1
            JOIN (
                SELECT
                  t0.wkey AS c1
                FROM
                  t0 
            ) AS subq_0
          ON true ));
      +------+
      | wkey |
      +------+
      |    1 |
      +------+
      1 row in set (0.00 sec)
       
      
      

      Attachments

        Activity

          People

            psergei Sergei Petrunia
            Wangdada HeShan
            Votes:
            0 Vote for this issue
            Watchers:
            3 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.