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

ERROR 1054 resolving a qualified, unprojected GROUP BY column when another group key has the same name

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Duplicate
    • 12.3.2
    • N/A
    • Optimizer
    • None
    • Not for Release Notes

    Description

      Description

      MariaDB Server 12.3.2 rejects a qualified column reference in HAVING even though the column is present in GROUP BY. The reduced query groups two derived tables by their respective `a` columns, and projects only a constant. Both qualified group keys are valid and unambiguous, but `HAVING x.a > 0` raises ERROR 1054.

      Projecting `x.a`, or giving the other table's group key a different name, makes the query succeed. A correlated subquery inside HAVING encounters the same problem, reported as an unknown column in WHERE.

      How to repeat

      SELECT 1 AS result
      FROM (SELECT 1 AS a) AS x
      CROSS JOIN (SELECT 2 AS a) AS y
      GROUP BY x.a, y.a
      HAVING x.a > 0;
      

      Actual result

       
      ERROR 1054 (42S22): Unknown column 'x.a' in 'HAVING'
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              chen7897 cl hl
              Votes:
              0 Vote for this issue
              Watchers:
              2 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.