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

Column name given by "AS" ignored (sub-query, group by context)

    XMLWordPrintable

    Details

      Description

      The attached example column-headings-minimal.sql produces duplicate column-headings despite the fact that the first column is configure with AS col_one.

      It seems that the relevant parts which trigger this (unexpected?) behaviour are:

      • join with a subquery
      • the sub-query contains an IFNULL or COALESCE
      • the outer query uses GROUP BY (remove it and the problem is no longer there)
      • it does not matter where one uses a "real" table or this virtual "seq_1_to..." tables
      • the second attached SQL example column-headings-less-minimal.sql shows some more columns with IFNULL in addition to COALESCE and also selects the "vanilla" sequence column.

      The example itself is "brain-damaged" of course, but I stumbled over this in a context where the SQL query is programmatically generated. I also think that whatever you do in the sub-query should not affect the column names of the outer query.

        Attachments

          Activity

            People

            Assignee:
            sanja Oleksandr Byelkin
            Reporter:
            rotdrop Claus-Justus Heine
            Votes:
            0 Vote for this issue
            Watchers:
            3 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.