Commit 07a17e30 authored by Norvald H. Ryeng's avatar Norvald H. Ryeng

Merge.

parents 61e428eb cac1cd88
...@@ -6010,7 +6010,7 @@ bool Item_ref::fix_fields(THD *thd, Item **reference) ...@@ -6010,7 +6010,7 @@ bool Item_ref::fix_fields(THD *thd, Item **reference)
if (from_field != not_found_field) if (from_field != not_found_field)
{ {
Item_field* fld; Item_field* fld;
if (!(fld= new Item_field(from_field))) if (!(fld= new Item_field(thd, last_checked_context, from_field)))
goto error; goto error;
thd->change_item_tree(reference, fld); thd->change_item_tree(reference, fld);
mark_as_dependent(thd, last_checked_context->select_lex, mark_as_dependent(thd, last_checked_context->select_lex,
......
...@@ -528,6 +528,8 @@ JOIN::prepare(Item ***rref_pointer_array, ...@@ -528,6 +528,8 @@ JOIN::prepare(Item ***rref_pointer_array,
if (having) if (having)
{ {
Query_arena backup, *arena;
arena= thd->activate_stmt_arena_if_needed(&backup);
nesting_map save_allow_sum_func= thd->lex->allow_sum_func; nesting_map save_allow_sum_func= thd->lex->allow_sum_func;
thd->where="having clause"; thd->where="having clause";
thd->lex->allow_sum_func|= 1 << select_lex_arg->nest_level; thd->lex->allow_sum_func|= 1 << select_lex_arg->nest_level;
...@@ -536,6 +538,10 @@ JOIN::prepare(Item ***rref_pointer_array, ...@@ -536,6 +538,10 @@ JOIN::prepare(Item ***rref_pointer_array,
(having->fix_fields(thd, &having) || (having->fix_fields(thd, &having) ||
having->check_cols(1))); having->check_cols(1)));
select_lex->having_fix_field= 0; select_lex->having_fix_field= 0;
select_lex->having= having;
if (arena)
thd->restore_active_arena(arena, &backup);
if (having_fix_rc || thd->is_error()) if (having_fix_rc || thd->is_error())
DBUG_RETURN(-1); /* purecov: inspected */ DBUG_RETURN(-1); /* purecov: inspected */
thd->lex->allow_sum_func= save_allow_sum_func; thd->lex->allow_sum_func= save_allow_sum_func;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment