diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/item_subselect.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index fb51b5561e9..30643ec8385 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -88,7 +88,14 @@ bool Item_subselect::fix_fields(THD *thd, TABLE_LIST *tables, Item **ref) if (have_to_be_excluded) engine->exclude(); substitution= 0; - return (*ref)->fix_fields(thd, tables, ref); + int ret= (*ref)->fix_fields(thd, tables, ref); + // We can't substitute aggregate functions (like (SELECT (max(i))) + if ((*ref)->with_sum_func) + { + my_error(ER_INVALID_GROUP_FUNC_USE, MYF(0)); + return 1; + } + return ret; } char const *save_where= thd->where; |