[MDEV-9669] Syntax error upon select from a view with a FROM subquery Created: 2016-03-02  Updated: 2016-03-04  Resolved: 2016-03-04

Status: Closed
Project: MariaDB Server
Component/s: Views
Affects Version/s: N/A
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Oleksandr Byelkin
Resolution: Fixed Votes: 0
Labels: None
Environment:

a6c0c01cec43731df3c58b4fdb68d3ac18e6c699


Issue Links:
Blocks
blocks MDEV-3944 Allow derived tables in VIEWS Closed
Relates
relates to MDEV-9664 Test MDEV-3944 (Allow derived tables ... Closed

 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`)))


Generated at Thu Feb 08 07:36:25 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.