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

With more than one CROSS JOIN columns of tables mentioned earlier in the FROM clause cannot be referenced in SELECT or WHERE clause (Error message: "Unknown column 'table.column' in 'where clause'")

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Duplicate
    • 10.1.41
    • N/A
    • N/A
    • None
    • Debian/Linux 9.10; Kernel 4.9.0-11-amd64; MariaDB Server version 10.1.41-MariaDB-0+deb9u1

    Description

      Yesterday I upgraded a Debian/Linux box from 9.9 to 9.10, which causes MariaDB to be upgraded from 10.1.38-MariaDB to 10.1.41-MariaDB-0+deb9u1

      As a result SELECT queries fail that reference columns of a table in their SELECT or WHERE clause, if the statement has at least two "CROSS JOIN" clauses and the table in question is referenced before these two "CROSS JOIN" statements.

      A minimal example looks like this:

      MariaDB [mariab_test]> CREATE TABLE `a` (`id` int(11) DEFAULT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
      Query OK, 0 rows affected (0.01 sec)
       
      MariaDB [mariab_test]> INSERT INTO a VALUES (1);
      Query OK, 1 row affected (0.01 sec)
       
      MariaDB [mariab_test]> SELECT a.id FROM a AS a1 CROSS JOIN a AS a2 CROSS JOIN a AS a3, a;
      +------+
      | id   |
      +------+
      |    1 |
      +------+
      1 row in set (0.00 sec)
       
      MariaDB [mariab_test]> SELECT a.* FROM a, a AS a1 CROSS JOIN a AS a2 CROSS JOIN a AS a3;
      +------+
      | id   |
      +------+
      |    1 |
      +------+
      1 row in set (0.00 sec)
       
      MariaDB [mariab_test]> SELECT a.id FROM a, a AS a1 CROSS JOIN a AS a2 CROSS JOIN a AS a3;
      ERROR 1054 (42S22): Unknown column 'a.id' in 'field list'
      MariaDB [mariab_test]> SELECT * FROM a, a AS a1 CROSS JOIN a AS a2 CROSS JOIN a AS a3 WHERE a.id=1;
      ERROR 1054 (42S22): Unknown column 'a.id' in 'where clause'
      MariaDB [mariab_test]> 
      

      Only the last two statements produce the error message; the other ones are included to show that with slightly different statements the produced results are as expected.

      Can someone reproduce this with a plain 10.1.41 version of MariaDB, or is this specific to the Debian package?

      Attachments

        Issue Links

          Activity

            alice Alice Sherepa added a comment -

            thanks! it was fixed by e746f451d57def4be6 commit by Igor Babaev:

            commit e746f451d57def4be679caafc29976741b3e89f7
            Author: Igor Babaev <igor@askmonty.org>
            Date:   Thu Aug 15 17:27:49 2019 -0700
             
                MDEV-20265 Unknown column in field list
                
                This patch corrects the fix of the patch for mdev-19421 that resolved
                the problem of parsing some embedded join expressions such as
                  t1 join t2 left join t3 on t2.a=t3.a on t1.a=t2.a.
                Yet the patch contained a bug that prevented proper context analysis
                of the queries where such expressions were used together with comma
                separated table references in from clauses.
            

            alice Alice Sherepa added a comment - thanks! it was fixed by e746f451d57def4be6 commit by Igor Babaev: commit e746f451d57def4be679caafc29976741b3e89f7 Author: Igor Babaev <igor@askmonty.org> Date: Thu Aug 15 17:27:49 2019 -0700   MDEV-20265 Unknown column in field list This patch corrects the fix of the patch for mdev-19421 that resolved the problem of parsing some embedded join expressions such as t1 join t2 left join t3 on t2.a=t3.a on t1.a=t2.a. Yet the patch contained a bug that prevented proper context analysis of the queries where such expressions were used together with comma separated table references in from clauses.

            Oh, I missed that issue and did not notice mine was a duplicate.
            Thanks alice for handling my report, and thanks to igor for the fix!

            crobbenhaar Clemens Robbenhaar added a comment - Oh, I missed that issue and did not notice mine was a duplicate. Thanks alice for handling my report, and thanks to igor for the fix!

            People

              Unassigned Unassigned
              crobbenhaar Clemens Robbenhaar
              Votes:
              0 Vote for this issue
              Watchers:
              2 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.