diff options
author | evgen@moonbone.local <> | 2008-03-27 19:49:32 +0300 |
---|---|---|
committer | evgen@moonbone.local <> | 2008-03-27 19:49:32 +0300 |
commit | 21c6145a6e70c06b36f55929223dc84edab952bf (patch) | |
tree | ca14d8fab0a56e30909c86fffffee0bc6e79fb83 /sql/item_subselect.cc | |
parent | 3a87bbfe42f23c562a37d63b4203dc24ed464632 (diff) | |
download | mariadb-git-21c6145a6e70c06b36f55929223dc84edab952bf.tar.gz |
Bug#27219: Aggregate functions in ORDER BY.
Mixing aggregate functions and non-grouping columns is not allowed in the
ONLY_FULL_GROUP_BY mode. However in some cases the error wasn't thrown because
of insufficient check.
In order to check more thoroughly the new algorithm employs a list of outer
fields used in a sum function and a SELECT_LEX::full_group_by_flag.
Each non-outer field checked to find out whether it's aggregated or not and
the current select is marked accordingly.
All outer fields that are used under an aggregate function are added to the
Item_sum::outer_fields list and later checked by the Item_sum::check_sum_func
function.
Diffstat (limited to 'sql/item_subselect.cc')
-rw-r--r-- | sql/item_subselect.cc | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index b3710841dfb..1c81a4ac3a1 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -1434,6 +1434,19 @@ Item_in_subselect::select_in_like_transformer(JOIN *join, Comp_creator *func) DBUG_ENTER("Item_in_subselect::select_in_like_transformer"); + { + /* + IN/SOME/ALL/ANY subqueries aren't support LIMIT clause. Without it + ORDER BY clause becomes meaningless thus we drop it here. + */ + SELECT_LEX *sl= current->master_unit()->first_select(); + for (; sl; sl= sl->next_select()) + { + if (sl->join) + sl->join->order= 0; + } + } + if (changed) { DBUG_RETURN(RES_OK); @@ -1468,6 +1481,7 @@ Item_in_subselect::select_in_like_transformer(JOIN *join, Comp_creator *func) transformed= 1; arena= thd->activate_stmt_arena_if_needed(&backup); + /* Both transformers call fix_fields() only for Items created inside them, and all that items do not make permanent changes in current item arena |