diff options
Diffstat (limited to 'sql/sql_union.cc')
-rw-r--r-- | sql/sql_union.cc | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 5cdf726f335..4b9221d0516 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -1,5 +1,5 @@ -/* Copyright (c) 2000, 2014, Oracle and/or its affiliates. - Copyright (c) 2010, 2014, SkySQL Ab. +/* Copyright (c) 2000, 2017, Oracle and/or its affiliates. + Copyright (c) 2010, 2017, Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -815,7 +815,18 @@ bool st_select_lex_unit::join_union_type_attributes(THD *thd_arg, List_iterator_fast<Item> itx(sl->item_list); for (uint holder_pos= 0 ; (item_tmp= itx++); holder_pos++) { - DBUG_ASSERT(item_tmp->fixed); + /* + If the outer query has a GROUP BY clause, an outer reference to this + query block may have been wrapped in a Item_outer_ref, which has not + been fixed yet. An Item_type_holder must be created based on a fixed + Item, so use the inner Item instead. + */ + DBUG_ASSERT(item_tmp->fixed || + (item_tmp->type() == Item::REF_ITEM && + ((Item_ref *)(item_tmp))->ref_type() == + Item_ref::OUTER_REF)); + if (!item_tmp->fixed) + item_tmp= item_tmp->real_item(); holders[holder_pos].add_argument(item_tmp); } } @@ -1936,4 +1947,3 @@ void st_select_lex_unit::set_unique_exclude() } } } - |