mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
Fix bug#7672 Unknown column error in order clause
When fixing Item_func_plus in ORDER BY clause field c is searched in all opened tables, but because c is an alias it wasn't found there. This patch adds a flag to select_lex which allows Item_field::fix_fields() to look up in select's item_list to find aliased fields. sql/item.cc: Fix bug#7672 Unknown column error in order clause When fixing fields in ORDER BY clause allow Item_field::fix_fields() to look up items in select's item list to find aliased fields. sql/sql_lex.cc: Fix bug#7672 Unknown column error in order clause sql/sql_lex.h: Fix bug#7672 Unknown column error in order clause Added flag to select_lex allowing Item_field::fix_fields to look up items in select's item list. sql/sql_select.cc: Fix bug#7672 Unknown column error in order clause mysql-test/t/select.test: Test case for bug#7672 Unknown column error in order clause mysql-test/r/select.result: Test case for bug#7672 Unknown column error in order clause
This commit is contained in:
@@ -6845,8 +6845,14 @@ find_order_in_list(THD *thd,TABLE_LIST *tables,ORDER *order,List<Item> &fields,
|
||||
return 0;
|
||||
}
|
||||
order->in_field_list=0;
|
||||
/* Allow lookup in select's item_list to find aliased fields */
|
||||
thd->lex.select_lex.is_item_list_lookup= 1;
|
||||
if ((*order->item)->fix_fields(thd,tables) || thd->fatal_error)
|
||||
{
|
||||
thd->lex.select_lex.is_item_list_lookup= 0;
|
||||
return 1; // Wrong field
|
||||
}
|
||||
thd->lex.select_lex.is_item_list_lookup= 0;
|
||||
all_fields.push_front(*order->item); // Add new field to field list
|
||||
order->item=(Item**) all_fields.head_ref();
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user