[MDEV-15177] parentheses in CTE, syntax error Created: 2018-02-02  Updated: 2018-04-12  Resolved: 2018-04-12

Status: Closed
Project: MariaDB Server
Component/s: Optimizer - CTE
Affects Version/s: 10.2
Fix Version/s: N/A

Type: Bug Priority: Minor
Reporter: Alice Sherepa Assignee: Alice Sherepa
Resolution: Won't Fix Votes: 0
Labels: None


 Description   

testcase

create table t1 (i int);
insert into t1 values (1),(2),(3);
(select * from t1);                                      #this works
(with cte as (select * from t1) select * from cte);      #but this returns syntax error
with cte as (select * from t1) (select * from cte UNION select * from t1);
with cte as (select * from t1) (select * from cte UNION select * from t1) LIMIT 1;

MariaDB [test]> create table t1 (i int);
Query OK, 0 rows affected (0.166 sec)
 
MariaDB [test]> insert into t1 values (1),(2),(3);
Query OK, 3 rows affected (0.025 sec)
Records: 3  Duplicates: 0  Warnings: 0
 
MariaDB [test]> (select * from t1);
+------+
| i    |
+------+
|    1 |
|    2 |
|    3 |
+------+
3 rows in set (0.000 sec)
 
MariaDB [test]> (with cte as (select * from t1) select * from cte);
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 'with cte as (select * from t1) select * from cte)' at line 1
MariaDB [test]> with cte as (select * from t1) (select * from cte UNION select * from t1);
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 'UNION select * from t1)' at line 1
MariaDB [test]> with cte as (select * from t1) (select * from cte UNION select * from t1) LIMIT 1;
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 'UNION select * from t1) LIMIT 1' at line 1



 Comments   
Comment by Igor Babaev [ 2018-04-11 ]

Alice,
Why do you consider all these as bugs? I don't see any. (See the SQL standard)

Comment by Alice Sherepa [ 2018-04-12 ]

Mysql 8.0 allows using brackets this way (testcase came out from mtr-tests, while importing)

Generated at Thu Feb 08 08:19:16 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.