mirror of
https://github.com/MariaDB/server.git
synced 2026-01-06 05:22:24 +03:00
Fix bug #12993 View column rename broken in subselect
When view column aliased in subselect alias is set on ref which represents field. When tmp table is created for subselect, it takes name of original field not ref. Because of this alias on view column in subselect is lost. Which results in reported error. Now when alias is set on ref, it's set on ref real item too. mysql-test/r/view.result: Test case for bug #12993 View column rename broken in subselect mysql-test/t/view.test: Test case for bug #12993 View column rename broken in subselect sql/sql_base.cc: Fix bug #12993 View column rename broken in subselect Now when alias is set on ref, it's set on ref real item too.
This commit is contained in:
@@ -2648,10 +2648,15 @@ find_field_in_view(THD *thd, TABLE_LIST *table_list,
|
||||
*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)
|
||||
thd->change_item_tree(ref, item);
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user