From 82da98556cf58f0fbb43c82e9c6ae1a887b6cf3d Mon Sep 17 00:00:00 2001 From: Oleksandr Byelkin Date: Mon, 25 Feb 2019 15:57:08 +0100 Subject: [PATCH 2/2] MDEV-18605: Loss of column aliases by using view and group Preserv column name with copy fields even if it is function and Co. diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 439853c2f66..0bc27f18d47 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -23914,7 +23914,9 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param, real_pos->type() == Item::COND_ITEM) && !real_pos->with_sum_func) { // Save for send fields + LEX_CSTRING real_name= pos->name; pos= real_pos; + pos->name= real_name; /* TODO: In most cases this result will be sent to the user. This should be changed to use copy_int or copy_real depending