1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

BUG#25106: A USING clause in combination with a VIEW results in column

aliases ignored
When a column reference to a column in JOIN USING is resolved and a new 
Item is created for this column the user defined name was lost.
This fix preserves the alias by setting the name of the new Item to the
original alias.
This commit is contained in:
gkodinov/kgeorge@macbook.gmz
2007-01-11 19:10:01 +02:00
parent a63df24a68
commit 15bcf13182
3 changed files with 49 additions and 0 deletions

View File

@ -2977,6 +2977,19 @@ find_field_in_natural_join(THD *thd, TABLE_LIST *table_ref, const char *name,
column reference. See create_view_field() for details.
*/
item= nj_col->create_item(thd);
/*
*ref != NULL means that *ref contains the item that we need to
replace. If the item was aliased by the user, set the alias to
the replacing item.
We need to set alias on both ref itself and on ref real item.
*/
if (*ref && !(*ref)->is_autogenerated_name)
{
item->set_name((*ref)->name, (*ref)->name_length,
system_charset_info);
item->real_item()->set_name((*ref)->name, (*ref)->name_length,
system_charset_info);
}
if (register_tree_change && arena)
thd->restore_active_arena(arena, &backup);