diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index f37c0966c938e..6fc2121fd2028 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -3235,7 +3235,6 @@ void st_select_lex::init_select() type= 0; db= null_clex_str; having= 0; - table_join_options= 0; select_lock= select_lock_type::NONE; in_sum_expr= with_wild= with_wild_returning= 0; options= 0; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 8973145e441db..4f578fea58ebf 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -1290,7 +1290,6 @@ class st_select_lex: public st_select_lex_node /* Structure to store fields that are used in the GROUP BY of this select */ List grouping_tmp_fields; - List udf_list; /* udf function calls stack */ List *index_hints; /* list of USE/FORCE/IGNORE INDEX */ /* This list is used to restore the names of items @@ -1354,7 +1353,6 @@ class st_select_lex: public st_select_lex_node /// Array of pointers to top elements of all_fields list Ref_ptr_array ref_pointer_array; - ulong table_join_options; /* number of items in select_list and HAVING clause used to get number @@ -1542,7 +1540,6 @@ class st_select_lex: public st_select_lex_node bool save_item_list_names(THD *thd); void restore_item_list_names(); bool set_item_list_names( List *overwrite ); - ulong get_table_join_options(); void set_lock_for_tables(thr_lock_type lock_type, bool for_update, bool skip_locks); /* diff --git a/sql/sql_select.cc b/sql/sql_select.cc index bf4e799347eaf..5c1dbec56bc93 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -516,7 +516,7 @@ void JOIN::init(THD *thd_arg, List &fields_arg, found_records= accepted_rows= 0; fetch_limit= HA_POS_ERROR; thd= thd_arg; - sum_funcs= sum_funcs2= 0; + sum_funcs= 0; procedure= 0; having= tmp_having= having_history= 0; having_is_correlated= false; @@ -530,7 +530,6 @@ void JOIN::init(THD *thd_arg, List &fields_arg, simple_order= 0; simple_group= 0; ordered_index_usage= ordered_index_void; - need_distinct= 0; skip_sort_order= 0; with_two_phase_optimization= 0; save_qep= 0; @@ -559,7 +558,6 @@ void JOIN::init(THD *thd_arg, List &fields_arg, no_rows_in_result_called= 0; positions= best_positions= 0; pushdown_query= 0; - original_join_tab= 0; explain= NULL; tmp_table_keep_current_rowid= 0; allowed_top_level_tables= 0; @@ -1462,7 +1460,6 @@ JOIN::prepare(TABLE_LIST *tables_init, COND *conds_init, uint og_num, select_lex, select_lex->select_number, this)); select_lex->join= this; join_list= &select_lex->top_join_list; - union_part= unit_arg->is_unit_op(); Json_writer_object trace_wrapper(thd); Json_writer_object trace_prepare(thd, "join_preparation"); @@ -2248,7 +2245,6 @@ JOIN::optimize_inner() do_send_rows = (unit->lim.get_select_limit()) ? 1 : 0; set_allowed_join_cache_types(); - need_distinct= TRUE; Json_writer_object trace_wrapper(thd); Json_writer_object trace_prepare(thd, "join_optimization"); @@ -2316,8 +2312,6 @@ JOIN::optimize_inner() select_lex->update_used_tables(); } - eval_select_list_used_tables(); - table_count= select_lex->leaf_tables.elements; if (select_lex->options & OPTION_SCHEMA_TABLE && @@ -3590,7 +3584,6 @@ int JOIN::optimize_stage2() tmp_table_param.precomputed_group_by= TRUE; if (join_tab->is_using_agg_loose_index_scan()) { - need_distinct= FALSE; tmp_table_param.precomputed_group_by= FALSE; } } @@ -3813,7 +3806,6 @@ bool JOIN::make_aggr_tables_info() if (join_tab && top_join_tab_count && tables_list) { join_tab[top_join_tab_count - 1].fields= &fields_list; - join_tab[top_join_tab_count - 1].all_fields= &all_fields; } /* @@ -3932,7 +3924,6 @@ bool JOIN::make_aggr_tables_info() //todo: new: curr_tab->ref_array= &items1; - curr_tab->all_fields= &tmp_all_fields1; curr_tab->fields= &tmp_fields_list1; DBUG_RETURN(thd->is_error()); @@ -4020,7 +4011,6 @@ bool JOIN::make_aggr_tables_info() // Need to set them now for correct group_fields setup, reset at the end. set_items_ref_array(items1); curr_tab->ref_array= &items1; - curr_tab->all_fields= &tmp_all_fields1; curr_tab->fields= &tmp_fields_list1; set_postjoin_aggr_write_func(curr_tab); @@ -4162,7 +4152,6 @@ bool JOIN::make_aggr_tables_info() curr_all_fields= &tmp_all_fields2; set_items_ref_array(items2); curr_tab->ref_array= &items2; - curr_tab->all_fields= &tmp_all_fields2; curr_tab->fields= &tmp_fields_list2; set_postjoin_aggr_write_func(curr_tab); @@ -4247,7 +4236,6 @@ bool JOIN::make_aggr_tables_info() JOIN_TAB *last_tab= join_tab + top_join_tab_count + aggr_tables - 1; // Set grouped fields on the last table last_tab->ref_array= &items3; - last_tab->all_fields= &tmp_all_fields3; last_tab->fields= &tmp_fields_list3; } if (make_sum_func_list(*curr_all_fields, *curr_fields_list, true)) @@ -15683,29 +15671,6 @@ void JOIN::drop_unused_derived_keys() } -/* - Evaluate the bitmap of used tables for items from the select list -*/ - -inline void JOIN::eval_select_list_used_tables() -{ - select_list_used_tables= 0; - Item *item; - List_iterator_fast it(fields_list); - while ((item= it++)) - { - select_list_used_tables|= item->used_tables(); - } - Item_outer_ref *ref; - List_iterator_fast ref_it(select_lex->inner_refs_list); - while ((ref= ref_it++)) - { - item= ref->outer_ref; - select_list_used_tables|= item->used_tables(); - } -} - - /* Determine {after which table we'll produce ordered set} @@ -17586,14 +17551,6 @@ void JOIN::cleanup(bool full) if (full) have_query_plan= QEP_DELETED; - if (original_join_tab) - { - /* Free the original optimized join created for the group_by_handler */ - join_tab= original_join_tab; - original_join_tab= 0; - table_count= original_table_count; - } - if (join_tab) { JOIN_TAB *tab; diff --git a/sql/sql_select.h b/sql/sql_select.h index 404692404a613..6afb47fb0ef2b 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -623,11 +623,6 @@ typedef struct st_join_table { It is only used to prune searches in best_extension_by_limited_search() */ table_map key_dependent; - /* - Tables that have expression in their attached condition clause that depends - on this table. - */ - table_map related_tables; /* Bitmap of TAB_INFO_* bits that encodes special line for EXPLAIN 'Extra' @@ -774,16 +769,13 @@ typedef struct st_join_table { /** List of topmost expressions in the select list. The *next* JOIN_TAB - in the plan should use it to obtain correct values. Same applicable to - all_fields. These lists are needed because after tmp tables functions - will be turned to fields. These variables are pointing to - tmp_fields_list[123]. Valid only for tmp tables and the last non-tmp - table in the query plan. + in the plan should use it to obtain correct values. This list is needed + because after tmp tables functions will be turned to fields. This + variable is pointing to tmp_fields_list[123]. Valid only for tmp tables + and the last non-tmp table in the query plan. @see JOIN::make_aggr_tables_info() */ List *fields; - /** List of all expressions in the select list */ - List *all_fields; /* Pointer to the ref array slice which to switch to before sending records. Valid only for tmp tables. @@ -1614,7 +1606,6 @@ class JOIN :public Sql_alloc group_list) */ bool group; - bool need_distinct; /** Indicates that grouping will be performed on the result set during @@ -1633,7 +1624,7 @@ class JOIN :public Sql_alloc setup_end_select_func */ bool sort_and_group; - bool first_record,full_join, no_field_update; + bool first_record,full_join; bool hash_join; bool do_send_rows; table_map const_table_map; @@ -1667,8 +1658,6 @@ class JOIN :public Sql_alloc make_join_statistics) */ table_map outer_join; - /* Bitmap of tables used in the select list items */ - table_map select_list_used_tables; /* Tables that has HA_NON_COMPARABLE_ROWID (does not support rowid) set */ table_map not_usable_rowid_map; /* Tables that have a possiblity to use EQ_ref */ @@ -1711,8 +1700,6 @@ class JOIN :public Sql_alloc POSITION *next_sort_position; /* Next free space in sort_positions */ Pushdown_query *pushdown_query; - JOIN_TAB *original_join_tab; - uint original_table_count; uint sort_space; /******* Join optimization state members start *******/ @@ -1785,8 +1772,6 @@ class JOIN :public Sql_alloc List group_fields, group_fields_cache; THD *thd; Item_sum **sum_funcs, ***sum_funcs_end; - /** second copy of sumfuncs (for queries with 2 temporary tables */ - Item_sum **sum_funcs2, ***sum_funcs_end2; Procedure *procedure; Item *having; Item *tmp_having; ///< To store having when processed temporary table @@ -1825,12 +1810,6 @@ class JOIN :public Sql_alloc */ bool no_rows_in_result_called; - /** - This is set if SQL_CALC_ROWS was calculated by filesort() - and should be taken from the appropriate JOIN_TAB - */ - bool filesort_found_rows; - bool subq_exit_fl; ROLLUP rollup; ///< Used with rollup @@ -1954,7 +1933,6 @@ class JOIN :public Sql_alloc const char *zero_result_cause; ///< not 0 if exec must return zero result - bool union_part; ///< this subselect is part of union enum join_optimization_state { NOT_OPTIMIZED=0, OPTIMIZATION_IN_PROGRESS=1, @@ -2134,7 +2112,6 @@ class JOIN :public Sql_alloc void drop_unused_derived_keys(); bool get_best_combination(); bool add_sorting_to_table(JOIN_TAB *tab, ORDER *order); - inline void eval_select_list_used_tables(); /* Return the table for which an index scan can be used to satisfy the sort order needed by the ORDER BY/(implicit) GROUP BY clause