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

Explicit column name error in CTE of UNION

    XMLWordPrintable

Details

    Description

      The bug described in MDEV-15478 is not fully resolved. When the CTE is used again with UNION in the main statement, it gives error #1054 - Unknown column 'col1' in 'field list'

      WITH cte (col1) AS
      (
        SELECT 1
        UNION
        SELECT 2
      )
      SELECT col1 FROM cte
      -- union statement added to example in MDEV-15478
      UNION
      SELECT col1 FROM cte
      

      This can currently be worked around with:

      WITH cte (col1) AS
      (
        SELECT 1 AS col1 -- alias required
        UNION
        SELECT 2
      )
      SELECT col1 FROM cte
      UNION
      SELECT col1 FROM cte
      

      Attachments

        Issue Links

          Activity

            People

              igor Igor Babaev
              tarrin Tarrin Wills
              Votes:
              0 Vote for this issue
              Watchers:
              4 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.