From 1248c654c494df6df3dedf610e322f69a85d3102 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Wed, 18 Nov 2020 13:21:19 -0800 Subject: MDEV-19179 Regression: SELECT ... UNION ... with inconsistent column names fails A bogus error message was issued when a condition was pushed into a materialized derived table or view specified as union of selects with aggregation when the corresponding columns of the selects had different names. This happened because the expression pushed into having clauses of the selects was adjusted for the names of the first select of the union. The easiest solution was to rename the columns of the other selects to be name compatible with the columns of the first select. Approved by Oleksandr Byelkin --- sql/item.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'sql/item.h') diff --git a/sql/item.h b/sql/item.h index a49f9e8e5e4..ed20074a8da 100644 --- a/sql/item.h +++ b/sql/item.h @@ -818,6 +818,12 @@ public: void set_name_for_rollback(THD *thd, const char *str, uint length, CHARSET_INFO *cs); void rename(char *new_name); + void share_name_with(Item *item) + { + name= item->name; + name_length= item->name_length; + is_autogenerated_name= item->is_autogenerated_name; + } void init_make_field(Send_field *tmp_field,enum enum_field_types type); virtual void cleanup(); virtual void make_field(THD *thd, Send_field *field); -- cgit v1.2.1