mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
Fixed bug #16603.
A subquery transformation changes the HAVING clause of the embedding query if the subquery contains a GROUP BY clause. Yet the split_sum_func2 function was not applied to the modified HAVING clause. This could result in wrong answers. mysql-test/r/subselect.result: Added a test case for bug #16603. mysql-test/t/subselect.test: Added a test case for bug #16603.
This commit is contained in:
@ -364,22 +364,8 @@ JOIN::prepare(Item ***rref_pointer_array,
|
||||
select_lex->having_fix_field= 0;
|
||||
if (having_fix_rc || thd->net.report_error)
|
||||
DBUG_RETURN(-1); /* purecov: inspected */
|
||||
if (having->with_sum_func)
|
||||
having->split_sum_func2(thd, ref_pointer_array, all_fields,
|
||||
&having, TRUE);
|
||||
thd->lex->allow_sum_func= save_allow_sum_func;
|
||||
}
|
||||
if (select_lex->inner_sum_func_list)
|
||||
{
|
||||
Item_sum *end=select_lex->inner_sum_func_list;
|
||||
Item_sum *item_sum= end;
|
||||
do
|
||||
{
|
||||
item_sum= item_sum->next;
|
||||
item_sum->split_sum_func2(thd, ref_pointer_array,
|
||||
all_fields, item_sum->ref_by, FALSE);
|
||||
} while (item_sum != end);
|
||||
}
|
||||
|
||||
if (!thd->lex->view_prepare_mode)
|
||||
{
|
||||
@ -397,6 +383,21 @@ JOIN::prepare(Item ***rref_pointer_array,
|
||||
}
|
||||
}
|
||||
|
||||
if (having && having->with_sum_func)
|
||||
having->split_sum_func2(thd, ref_pointer_array, all_fields,
|
||||
&having, TRUE);
|
||||
if (select_lex->inner_sum_func_list)
|
||||
{
|
||||
Item_sum *end=select_lex->inner_sum_func_list;
|
||||
Item_sum *item_sum= end;
|
||||
do
|
||||
{
|
||||
item_sum= item_sum->next;
|
||||
item_sum->split_sum_func2(thd, ref_pointer_array,
|
||||
all_fields, item_sum->ref_by, FALSE);
|
||||
} while (item_sum != end);
|
||||
}
|
||||
|
||||
if (setup_ftfuncs(select_lex)) /* should be after having->fix_fields */
|
||||
DBUG_RETURN(-1);
|
||||
|
||||
|
Reference in New Issue
Block a user