Commit f2033df6 authored by Igor Babaev's avatar Igor Babaev

More thorough correction of the patch that complemented the patch for mdev-10855

parent 03366559
...@@ -334,12 +334,12 @@ ORDER *st_select_lex::find_common_window_func_partition_fields(THD *thd) ...@@ -334,12 +334,12 @@ ORDER *st_select_lex::find_common_window_func_partition_fields(THD *thd)
Item *item; Item *item;
DBUG_ASSERT(window_funcs.elements); DBUG_ASSERT(window_funcs.elements);
List_iterator_fast<Item_window_func> it(window_funcs); List_iterator_fast<Item_window_func> it(window_funcs);
Item_window_func *wf= it++; Item_window_func *first_wf= it++;
if (!wf->window_spec->partition_list) if (!first_wf->window_spec->partition_list)
return 0; return 0;
List<Item> common_fields; List<Item> common_fields;
uint first_partition_elements= 0; uint first_partition_elements= 0;
for (ord= wf->window_spec->partition_list->first; ord; ord= ord->next) for (ord= first_wf->window_spec->partition_list->first; ord; ord= ord->next)
{ {
if ((*ord->item)->real_item()->type() == Item::FIELD_ITEM) if ((*ord->item)->real_item()->type() == Item::FIELD_ITEM)
common_fields.push_back(*ord->item, thd->mem_root); common_fields.push_back(*ord->item, thd->mem_root);
...@@ -347,8 +347,9 @@ ORDER *st_select_lex::find_common_window_func_partition_fields(THD *thd) ...@@ -347,8 +347,9 @@ ORDER *st_select_lex::find_common_window_func_partition_fields(THD *thd)
} }
if (window_specs.elements == 1 && if (window_specs.elements == 1 &&
common_fields.elements == first_partition_elements) common_fields.elements == first_partition_elements)
return wf->window_spec->partition_list->first; return first_wf->window_spec->partition_list->first;
List_iterator<Item> li(common_fields); List_iterator<Item> li(common_fields);
Item_window_func *wf;
while (common_fields.elements && (wf= it++)) while (common_fields.elements && (wf= it++))
{ {
if (!wf->window_spec->partition_list) if (!wf->window_spec->partition_list)
...@@ -368,11 +369,9 @@ ORDER *st_select_lex::find_common_window_func_partition_fields(THD *thd) ...@@ -368,11 +369,9 @@ ORDER *st_select_lex::find_common_window_func_partition_fields(THD *thd)
if (!common_fields.elements) if (!common_fields.elements)
return 0; return 0;
if (common_fields.elements == first_partition_elements) if (common_fields.elements == first_partition_elements)
return wf->window_spec->partition_list->first; return first_wf->window_spec->partition_list->first;
SQL_I_List<ORDER> res_list; SQL_I_List<ORDER> res_list;
it.rewind(); for (ord= first_wf->window_spec->partition_list->first, item= li++;
wf= it++;
for (ord= wf->window_spec->partition_list->first, item= li++;
ord; ord= ord->next) ord; ord= ord->next)
{ {
if (item != *ord->item) if (item != *ord->item)
......
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