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

Recursive CTE does not work as subquery in some cases

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 10.2, 10.2.10
    • Fix Version/s: 10.2.12
    • Component/s: Optimizer - CTE
    • Labels:
      None
    • Environment:
      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

            Assignee:
            shagalla Galina Shalygina (Inactive)
            Reporter:
            Rich Rich Theobald
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: