[MDEV-27323] Column name given by "AS" ignored (sub-query, group by context) Created: 2021-12-20  Updated: 2023-04-27

Status: Confirmed
Project: MariaDB Server
Component/s: Data Manipulation - Subquery
Affects Version/s: 10.3.32, 10.5.13, 10.6.5, 10.2, 10.3, 10.4, 10.5, 10.6, 10.7
Fix Version/s: 10.4, 10.5, 10.6

Type: Bug Priority: Major
Reporter: Claus-Justus Heine Assignee: Oleksandr Byelkin
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Gentoo Linux


Attachments: File column-headings-less-minimal.sql     File column-headings-minimal.sql    

 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.


Generated at Thu Feb 08 09:52:03 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.