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

parentheses in CTE, syntax error

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Won't Fix
    • 10.2
    • N/A
    • Optimizer - CTE
    • 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
      

      Attachments

        Activity

          People

            alice Alice Sherepa
            alice Alice Sherepa
            Votes:
            0 Vote for this issue
            Watchers:
            3 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.