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

Syntax error upon select from a view with a FROM subquery

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • N/A
    • N/A
    • Views
    • None
    • a6c0c01cec43731df3c58b4fdb68d3ac18e6c699

    Description

      drop view v1;
      drop table t1, t2, t3;
       
      create table t1 (i int);
      insert into t1 values (1),(2);
       
      create table t2 (j int);
      insert into t2 values (3),(4);
       
      create table t3 (k int);
      insert into t3 values (5),(6);
       
      select * from t1 left join ( select * from t2 inner join t3 ) al on (i=k);
       
      create view v1 as 
      select * from t1 left join ( select * from t2 inner join t3 ) al on (i=k);
       
      select * from v1;
      

      Select works all right, and the view gets created without any errors, but select from the view fails:

      MariaDB [test]> select * from t1 left join ( select * from t2 inner join t3 ) al on (i=k);
      +------+------+------+
      | i    | j    | k    |
      +------+------+------+
      |    1 | NULL | NULL |
      |    2 | NULL | NULL |
      +------+------+------+
      2 rows in set (0.00 sec)
       
      MariaDB [test]> 
      MariaDB [test]> create view v1 as 
          -> select * from t1 left join ( select * from t2 inner join t3 ) al on (i=k);
      Query OK, 0 rows affected (0.01 sec)
       
      MariaDB [test]> 
      MariaDB [test]> select * from v1;
      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 ')) `al` on((`test`.`t1`.`i` = `al`.`k`)))' at line 1
      

      SHOW CREATE VIEW also fails. The frm file contains the following as a query:

      select `test`.`t1`.`i` AS `i`,`al`.`j` AS `j`,`al`.`k` AS `k` from (`test`.`t1` left join (select `test`.`t2`.`j` AS `j`,`test`.`t3`.`k` AS `k` from (`test`.`t2` left join `test`.`t3`)) `al` on((`test`.`t1`.`i` = `al`.`k`)))
      

      Attachments

        Issue Links

          Activity

            People

              sanja Oleksandr Byelkin
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              1 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.