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

CYCLE clause incorrectly reports an existing column as unknown when column order differs from CTE output

    XMLWordPrintable

Details

    • Unexpected results

    Description

      MariaDB incorrectly reports an existing CTE column as unknown when the column order in the CYCLE clause differs from the CTE output column order.

      Steps to reproduce:

      1. Execute the following query:

      WITH RECURSIVE cte(a, b) AS (
      SELECT 1, 10
      )
      CYCLE a, b RESTRICT
      SELECT * FROM cte;

      Result:
      The query executes successfully and returns one row: (1, 10).

      2. Execute the same query with the CYCLE columns in reverse order:

      WITH RECURSIVE cte(a, b) AS (
      SELECT 1, 10
      )
      CYCLE b, a RESTRICT
      SELECT * FROM cte;

      Actual result:
      ERROR 1054 (42S22): Unknown column 'a' in 'CYCLE clause'

      Expected result:
      Both queries should execute successfully because columns a and b are explicitly defined in the CTE. Changing their order in the CYCLE clause should not produce an unknown-column error.

      Attachments

        Issue Links

          Activity

            People

              psergei Sergei Petrunia
              zrcl Ruichen Zhang
              Sergei Petrunia Sergei Petrunia
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.