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

Recursive CTE does not work as subquery in some cases

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Fixed
    • 10.2.10, 10.2(EOL)
    • 10.2.12
    • Optimizer - CTE
    • None
    • Ubuntu 14.04

    Description

      The documentation doesn't explicitly say recursive CTEs are supported in subqueries, however, I am confused as to why it works in some but not others.

      Test case:

      MariaDB [test]> WITH RECURSIVE foo AS ( SELECT 1 UNION SELECT 1 FROM foo ) SELECT 1;
      +---+
      | 1 |
      +---+
      | 1 |
      +---+
      1 row in set (0.00 sec)
       
      MariaDB [test]> SELECT * FROM ( WITH RECURSIVE foo AS ( SELECT 1 UNION SELECT 1 FROM foo ) SELECT 1 ) bar;
      +---+
      | 1 |
      +---+
      | 1 |
      +---+
      1 row in set (0.00 sec)
       
      MariaDB [test]> SET @temp = ( WITH RECURSIVE foo AS ( SELECT 1 UNION SELECT 1 FROM foo ) SELECT 1 );
      ERROR 1146 (42S02): Table 'test.foo' doesn't exist
      

      Attachments

        Activity

          People

            shagalla Galina Shalygina (Inactive)
            Rich Rich Theobald
            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.