diff options
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r-- | sql/sql_select.cc | 44 |
1 files changed, 18 insertions, 26 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 823e3ed88bf..fac0b03cbbc 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -12,7 +12,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */ + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ /** @file @@ -1315,8 +1315,9 @@ JOIN::prepare(TABLE_LIST *tables_init, item->max_length))) real_order= TRUE; - if (item->with_sum_func() && item->type() != Item::SUM_FUNC_ITEM) - item->split_sum_func(thd, ref_ptrs, all_fields, 0); + if ((item->with_sum_func() && item->type() != Item::SUM_FUNC_ITEM) || + item->with_window_func) + item->split_sum_func(thd, ref_ptrs, all_fields, SPLIT_SUM_SELECT); } if (!real_order) order= NULL; @@ -9961,7 +9962,7 @@ JOIN_TAB *next_linear_tab(JOIN* join, JOIN_TAB* tab, } /* If no more JOIN_TAB's on the top level */ - if (++tab == join->join_tab + join->top_join_tab_count + join->aggr_tables) + if (++tab >= join->join_tab + join->exec_join_tab_cnt() + join->aggr_tables) return NULL; if (include_bush_roots == WITHOUT_BUSH_ROOTS && tab->bush_children) @@ -17409,7 +17410,11 @@ Field *Item::tmp_table_field_from_field_type_maybe_null(TABLE *table, const Tmp_field_param *param, bool is_explicit_null) { - DBUG_ASSERT(!param->make_copy_field()); + /* + item->type() == CONST_ITEM excluded due to making fields for counter + With help of Item_uint + */ + DBUG_ASSERT(!param->make_copy_field() || type() == CONST_ITEM); DBUG_ASSERT(!is_result_field()); Field *result; if ((result= tmp_table_field_from_field_type(table))) @@ -23859,6 +23864,10 @@ int setup_order(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables, my_error(ER_WINDOW_FUNCTION_IN_WINDOW_SPEC, MYF(0)); return 1; } + if (from_window_spec && (*order->item)->with_sum_func() && + (*order->item)->type() != Item::SUM_FUNC_ITEM) + (*order->item)->split_sum_func(thd, ref_pointer_array, + all_fields, SPLIT_SUM_SELECT); } return 0; } @@ -23926,6 +23935,10 @@ setup_group(THD *thd, Ref_ptr_array ref_pointer_array, TABLE_LIST *tables, my_error(ER_WINDOW_FUNCTION_IN_WINDOW_SPEC, MYF(0)); return 1; } + if (from_window_spec && (*ord->item)->with_sum_func() && + (*ord->item)->type() != Item::SUM_FUNC_ITEM) + (*ord->item)->split_sum_func(thd, ref_pointer_array, + all_fields, SPLIT_SUM_SELECT); } if (thd->variables.sql_mode & MODE_ONLY_FULL_GROUP_BY && context_analysis_place == IN_GROUP_BY) @@ -28260,27 +28273,6 @@ AGGR_OP::end_send() } else { - /* - In case we have window functions present, an extra step is required - to compute all the fields from the temporary table. - In case we have a compound expression such as: expr + expr, - where one of the terms has a window function inside it, only - after computing window function values we actually know the true - final result of the compounded expression. - - Go through all the func items and save their values once again in the - corresponding temp table fields. Do this for each row in the table. - */ - if (join_tab->window_funcs_step) - { - Item **func_ptr= join_tab->tmp_table_param->items_to_copy; - Item *func; - for (; (func = *func_ptr) ; func_ptr++) - { - if (func->with_window_func) - func->save_in_result_field(true); - } - } rc= evaluate_join_record(join, join_tab, 0); } } |