From 72bc6d7364f7cf6cae49c74cf1e56832053f91eb Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Sat, 5 Oct 2013 13:19:45 +0400 Subject: [PATCH] MDEV-3798: EXPLAIN UPDATE/DELETE - Address review feedback: more renames --- sql/opt_range.cc | 43 +++++++------ sql/opt_range.h | 14 ++-- sql/sql_delete.cc | 64 +++++++++--------- sql/sql_explain.cc | 15 +++-- sql/sql_explain.h | 12 ++-- sql/sql_join_cache.cc | 24 +++---- sql/sql_join_cache.h | 6 +- sql/sql_lex.cc | 12 ++-- sql/sql_lex.h | 4 +- sql/sql_select.cc | 146 +++++++++++++++++++++--------------------- 10 files changed, 173 insertions(+), 167 deletions(-) diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 2e32009bc54..cee72be7bda 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -11940,25 +11940,26 @@ void QUICK_SELECT_I::add_key_name(String *str, bool *first) } -void QUICK_RANGE_SELECT::save_info(MEM_ROOT *alloc, Explain_quick_select *qpf) +void QUICK_RANGE_SELECT::save_info(MEM_ROOT *alloc, + Explain_quick_select *explain) { - qpf->quick_type= QS_TYPE_RANGE; - qpf->range.set(alloc, head->key_info[index].name, max_used_key_length); + explain->quick_type= QS_TYPE_RANGE; + explain->range.set(alloc, head->key_info[index].name, max_used_key_length); } void QUICK_GROUP_MIN_MAX_SELECT::save_info(MEM_ROOT *alloc, - Explain_quick_select *qpf) + Explain_quick_select *explain) { - qpf->quick_type= QS_TYPE_GROUP_MIN_MAX; - qpf->range.set(alloc, head->key_info[index].name, max_used_key_length); + explain->quick_type= QS_TYPE_GROUP_MIN_MAX; + explain->range.set(alloc, head->key_info[index].name, max_used_key_length); } void QUICK_INDEX_SORT_SELECT::save_info(MEM_ROOT *alloc, - Explain_quick_select *qpf) + Explain_quick_select *explain) { - qpf->quick_type= get_type(); + explain->quick_type= get_type(); QUICK_RANGE_SELECT *quick; Explain_quick_select *child_qpf; @@ -11966,14 +11967,14 @@ void QUICK_INDEX_SORT_SELECT::save_info(MEM_ROOT *alloc, while ((quick= it++)) { child_qpf= new Explain_quick_select; - qpf->children.push_back(child_qpf); + explain->children.push_back(child_qpf); quick->save_info(alloc, child_qpf); } if (pk_quick_select) { child_qpf= new Explain_quick_select; - qpf->children.push_back(child_qpf); + explain->children.push_back(child_qpf); pk_quick_select->save_info(alloc, child_qpf); } } @@ -11983,15 +11984,15 @@ void QUICK_INDEX_SORT_SELECT::save_info(MEM_ROOT *alloc, first */ void QUICK_INDEX_INTERSECT_SELECT::save_info(MEM_ROOT *alloc, - Explain_quick_select *qpf) + Explain_quick_select *explain) { - qpf->quick_type= get_type(); + explain->quick_type= get_type(); Explain_quick_select *child_qpf; if (pk_quick_select) { child_qpf= new Explain_quick_select; - qpf->children.push_back(child_qpf); + explain->children.push_back(child_qpf); pk_quick_select->save_info(alloc, child_qpf); } @@ -12000,7 +12001,7 @@ void QUICK_INDEX_INTERSECT_SELECT::save_info(MEM_ROOT *alloc, while ((quick= it++)) { child_qpf= new Explain_quick_select; - qpf->children.push_back(child_qpf); + explain->children.push_back(child_qpf); quick->save_info(alloc, child_qpf); } @@ -12008,39 +12009,39 @@ void QUICK_INDEX_INTERSECT_SELECT::save_info(MEM_ROOT *alloc, void QUICK_ROR_INTERSECT_SELECT::save_info(MEM_ROOT *alloc, - Explain_quick_select *qpf) + Explain_quick_select *explain) { - qpf->quick_type= get_type(); + explain->quick_type= get_type(); QUICK_SELECT_WITH_RECORD *qr; List_iterator_fast it(quick_selects); while ((qr= it++)) { Explain_quick_select *child_qpf= new Explain_quick_select; - qpf->children.push_back(child_qpf); + explain->children.push_back(child_qpf); qr->quick->save_info(alloc, child_qpf); } if (cpk_quick) { Explain_quick_select *child_qpf= new Explain_quick_select; - qpf->children.push_back(child_qpf); + explain->children.push_back(child_qpf); cpk_quick->save_info(alloc, child_qpf); } } void QUICK_ROR_UNION_SELECT::save_info(MEM_ROOT *alloc, - Explain_quick_select *qpf) + Explain_quick_select *explain) { - qpf->quick_type= get_type(); + explain->quick_type= get_type(); QUICK_SELECT_I *quick; List_iterator_fast it(quick_selects); while ((quick= it++)) { Explain_quick_select *child_qpf= new Explain_quick_select; - qpf->children.push_back(child_qpf); + explain->children.push_back(child_qpf); quick->save_info(alloc, child_qpf); } } diff --git a/sql/opt_range.h b/sql/opt_range.h index 9bc19927fd0..23274466990 100644 --- a/sql/opt_range.h +++ b/sql/opt_range.h @@ -346,7 +346,7 @@ public: void add_key_name(String *str, bool *first); /* Save information about quick select's query plan */ - virtual void save_info(MEM_ROOT *alloc, Explain_quick_select *qpf)= 0; + virtual void save_info(MEM_ROOT *alloc, Explain_quick_select *explain)= 0; /* Return 1 if any index used by this quick select @@ -473,7 +473,7 @@ public: { file->position(record); } int get_type() { return QS_TYPE_RANGE; } void add_keys_and_lengths(String *key_names, String *used_lengths); - void save_info(MEM_ROOT *alloc, Explain_quick_select *qpf); + void save_info(MEM_ROOT *alloc, Explain_quick_select *explain); #ifndef DBUG_OFF void dbug_dump(int indent, bool verbose); #endif @@ -610,7 +610,7 @@ public: #ifndef DBUG_OFF void dbug_dump(int indent, bool verbose); #endif - void save_info(MEM_ROOT *alloc, Explain_quick_select *qpf); + void save_info(MEM_ROOT *alloc, Explain_quick_select *explain); bool push_quick_back(QUICK_RANGE_SELECT *quick_sel_range); @@ -674,7 +674,7 @@ public: int get_next(); int get_type() { return QS_TYPE_INDEX_INTERSECT; } void add_keys_and_lengths(String *key_names, String *used_lengths); - void save_info(MEM_ROOT *alloc, Explain_quick_select *qpf); + void save_info(MEM_ROOT *alloc, Explain_quick_select *explain); }; @@ -712,7 +712,7 @@ public: bool unique_key_range() { return false; } int get_type() { return QS_TYPE_ROR_INTERSECT; } void add_keys_and_lengths(String *key_names, String *used_lengths); - void save_info(MEM_ROOT *alloc, Explain_quick_select *qpf); + void save_info(MEM_ROOT *alloc, Explain_quick_select *explain); bool is_keys_used(const MY_BITMAP *fields); #ifndef DBUG_OFF void dbug_dump(int indent, bool verbose); @@ -791,7 +791,7 @@ public: bool unique_key_range() { return false; } int get_type() { return QS_TYPE_ROR_UNION; } void add_keys_and_lengths(String *key_names, String *used_lengths); - void save_info(MEM_ROOT *alloc, Explain_quick_select *qpf); + void save_info(MEM_ROOT *alloc, Explain_quick_select *explain); bool is_keys_used(const MY_BITMAP *fields); #ifndef DBUG_OFF void dbug_dump(int indent, bool verbose); @@ -940,7 +940,7 @@ public: #endif bool is_agg_distinct() { return have_agg_distinct; } bool loose_scan_is_scanning() { return is_index_scan; } - void save_info(MEM_ROOT *alloc, Explain_quick_select *qpf); + void save_info(MEM_ROOT *alloc, Explain_quick_select *explain); }; diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 58deae4162a..518bdc6ab43 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -53,59 +53,60 @@ void Delete_plan::save_explain_data(Explain_query *query) { - QPF_delete* qpf= new QPF_delete; + Explain_delete* explain= new Explain_delete; if (deleting_all_rows) { - qpf->deleting_all_rows= true; - qpf->select_type= "SIMPLE"; + explain->deleting_all_rows= true; + explain->select_type= "SIMPLE"; } else { - qpf->deleting_all_rows= false; - Update_plan::save_explain_data_intern(query, qpf); + explain->deleting_all_rows= false; + Update_plan::save_explain_data_intern(query, explain); } - query->upd_del_plan= qpf; + query->upd_del_plan= explain; } void Update_plan::save_explain_data(Explain_query *query) { - QPF_update* qpf= new QPF_update; - save_explain_data_intern(query, qpf); - query->upd_del_plan= qpf; + Explain_update* explain= new Explain_update; + save_explain_data_intern(query, explain); + query->upd_del_plan= explain; } -void Update_plan::save_explain_data_intern(Explain_query *query, QPF_update *qpf) +void Update_plan::save_explain_data_intern(Explain_query *query, + Explain_update *explain) { - qpf->select_type= "SIMPLE"; - qpf->table_name.append(table->pos_in_table_list->alias); + explain->select_type= "SIMPLE"; + explain->table_name.append(table->pos_in_table_list->alias); if (impossible_where) { - qpf->impossible_where= true; + explain->impossible_where= true; return; } - qpf->impossible_where= false; + explain->impossible_where= false; select_lex->set_explain_type(TRUE); - qpf->select_type= select_lex->type; + explain->select_type= select_lex->type; /* Partitions */ { #ifdef WITH_PARTITION_STORAGE_ENGINE partition_info *part_info; if ((part_info= table->part_info)) { - make_used_partitions_str(part_info, &qpf->used_partitions); - qpf->used_partitions_set= true; + make_used_partitions_str(part_info, &explain->used_partitions); + explain->used_partitions_set= true; } else - qpf->used_partitions_set= false; + explain->used_partitions_set= false; #else /* just produce empty column if partitioning is not compiled in */ - qpf->used_partitions_set= false; + explain->used_partitions_set= false; #endif } @@ -118,42 +119,43 @@ void Update_plan::save_explain_data_intern(Explain_query *query, QPF_update *qpf (quick_type == QUICK_SELECT_I::QS_TYPE_INDEX_INTERSECT) || (quick_type == QUICK_SELECT_I::QS_TYPE_ROR_INTERSECT) || (quick_type == QUICK_SELECT_I::QS_TYPE_ROR_UNION)) - qpf->jtype= JT_INDEX_MERGE; + explain->jtype= JT_INDEX_MERGE; else - qpf->jtype= JT_RANGE; + explain->jtype= JT_RANGE; } else { if (index == MAX_KEY) - qpf->jtype= JT_ALL; + explain->jtype= JT_ALL; else - qpf->jtype= JT_NEXT; + explain->jtype= JT_NEXT; } - qpf->using_where= test(select && select->cond); - qpf->using_filesort= using_filesort; + explain->using_where= test(select && select->cond); + explain->using_filesort= using_filesort; - make_possible_keys_line(table, possible_keys, &qpf->possible_keys_line); + make_possible_keys_line(table, possible_keys, &explain->possible_keys_line); /* Calculate key_len */ if (select && select->quick) { - select->quick->add_keys_and_lengths(&qpf->key_str, &qpf->key_len_str); + select->quick->add_keys_and_lengths(&explain->key_str, &explain->key_len_str); } else { if (index != MAX_KEY) { - qpf->key_str.append(table->key_info[index].name); + explain->key_str.append(table->key_info[index].name); } // key_len stays NULL } - qpf->rows= select ? select->records : table_rows; + explain->rows= select ? select->records : table_rows; if (select && select->quick && select->quick->get_type() == QUICK_SELECT_I::QS_TYPE_RANGE) { - explain_append_mrr_info((QUICK_RANGE_SELECT*)select->quick, &qpf->mrr_type); + explain_append_mrr_info((QUICK_RANGE_SELECT*)select->quick, + &explain->mrr_type); } bool skip= updating_a_view; @@ -173,7 +175,7 @@ void Update_plan::save_explain_data_intern(Explain_query *query, QPF_update *qpf clauses. */ if (!(unit->item && unit->item->eliminated)) - qpf->add_child(unit->first_select()->select_number); + explain->add_child(unit->first_select()->select_number); } } diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc index 248dc2b12be..0623ef0be8e 100644 --- a/sql/sql_explain.cc +++ b/sql/sql_explain.cc @@ -511,7 +511,8 @@ int Explain_table_access::print_explain(select_result_sink *output, uint8 explai /* - Elements in this array match members of enum Extra_tag, defined in opt_qpf.h. + Elements in this array match members of enum Extra_tag, defined in + sql_explain.h */ const char * extra_tag_text[]= @@ -740,8 +741,9 @@ void Explain_quick_select::print_key_len(String *str) } -int QPF_delete::print_explain(Explain_query *query, select_result_sink *output, - uint8 explain_flags) +int Explain_delete::print_explain(Explain_query *query, + select_result_sink *output, + uint8 explain_flags) { if (deleting_all_rows) { @@ -754,13 +756,14 @@ int QPF_delete::print_explain(Explain_query *query, select_result_sink *output, } else { - return QPF_update::print_explain(query, output, explain_flags); + return Explain_update::print_explain(query, output, explain_flags); } } -int QPF_update::print_explain(Explain_query *query, select_result_sink *output, - uint8 explain_flags) +int Explain_update::print_explain(Explain_query *query, + select_result_sink *output, + uint8 explain_flags) { StringBuffer<64> extra_str; if (impossible_where) diff --git a/sql/sql_explain.h b/sql/sql_explain.h index ef36cb4a44d..66e8b1be109 100644 --- a/sql/sql_explain.h +++ b/sql/sql_explain.h @@ -172,7 +172,7 @@ public: bool using_filesort; }; -class QPF_delete; +class Explain_delete; /* @@ -226,8 +226,8 @@ public: Explain_union *get_union(uint select_id); - /* QPF_delete inherits from QPF_update */ - QPF_update *upd_del_plan; + /* Explain_delete inherits from Explain_update */ + Explain_update *upd_del_plan; /* Produce a tabular EXPLAIN output */ int print_explain(select_result_sink *output, uint8 explain_flags); @@ -448,7 +448,7 @@ private: Also, it can have UPDATE operation options, but currently there aren't any. */ -class QPF_update : public Explain_node +class Explain_update : public Explain_node { public: virtual enum explain_node_type get_type() { return EXPLAIN_UPDATE; } @@ -479,10 +479,10 @@ public: /* - Query Plan Footprint for a single-table DELETE. + Explain data of a single-table DELETE. */ -class QPF_delete: public QPF_update +class Explain_delete: public Explain_update { public: /* diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc index 040e596d283..8b505b75272 100644 --- a/sql/sql_join_cache.cc +++ b/sql/sql_join_cache.cc @@ -2568,22 +2568,22 @@ finish: none */ -void JOIN_CACHE::save_explain_data(struct st_explain_bka_type *qpf) +void JOIN_CACHE::save_explain_data(struct st_explain_bka_type *explain) { - qpf->incremental= test(prev_cache); + explain->incremental= test(prev_cache); switch (get_join_alg()) { case BNL_JOIN_ALG: - qpf->join_alg= "BNL"; + explain->join_alg= "BNL"; break; case BNLH_JOIN_ALG: - qpf->join_alg= "BNLH"; + explain->join_alg= "BNLH"; break; case BKA_JOIN_ALG: - qpf->join_alg= "BKA"; + explain->join_alg= "BKA"; break; case BKAH_JOIN_ALG: - qpf->join_alg= "BKAH"; + explain->join_alg= "BKAH"; break; default: DBUG_ASSERT(0); @@ -2613,17 +2613,17 @@ static void add_mrr_explain_info(String *str, uint mrr_mode, handler *file) } } -void JOIN_CACHE_BKA::save_explain_data(struct st_explain_bka_type *qpf) +void JOIN_CACHE_BKA::save_explain_data(struct st_explain_bka_type *explain) { - JOIN_CACHE::save_explain_data(qpf); - add_mrr_explain_info(&qpf->mrr_type, mrr_mode, join_tab->table->file); + JOIN_CACHE::save_explain_data(explain); + add_mrr_explain_info(&explain->mrr_type, mrr_mode, join_tab->table->file); } -void JOIN_CACHE_BKAH::save_explain_data(struct st_explain_bka_type *qpf) +void JOIN_CACHE_BKAH::save_explain_data(struct st_explain_bka_type *explain) { - JOIN_CACHE::save_explain_data(qpf); - add_mrr_explain_info(&qpf->mrr_type, mrr_mode, join_tab->table->file); + JOIN_CACHE::save_explain_data(explain); + add_mrr_explain_info(&explain->mrr_type, mrr_mode, join_tab->table->file); } diff --git a/sql/sql_join_cache.h b/sql/sql_join_cache.h index 0b03f2b8bab..9dae7fb24e0 100644 --- a/sql/sql_join_cache.h +++ b/sql/sql_join_cache.h @@ -658,7 +658,7 @@ public: enum_nested_loop_state join_records(bool skip_last); /* Add a comment on the join algorithm employed by the join cache */ - virtual void save_explain_data(struct st_explain_bka_type *qpf); + virtual void save_explain_data(struct st_explain_bka_type *explain); THD *thd(); @@ -1336,7 +1336,7 @@ public: /* Check index condition of the joined table for a record from BKA cache */ bool skip_index_tuple(range_id_t range_info); - void save_explain_data(struct st_explain_bka_type *qpf); + void save_explain_data(struct st_explain_bka_type *explain); }; @@ -1427,5 +1427,5 @@ public: /* Check index condition of the joined table for a record from BKAH cache */ bool skip_index_tuple(range_id_t range_info); - void save_explain_data(struct st_explain_bka_type *qpf); + void save_explain_data(struct st_explain_bka_type *explain); }; diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index fd8d07f90aa..bd31200e749 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -4264,12 +4264,12 @@ int st_select_lex_unit::save_union_explain(Explain_query *output) const char *msg="Query plan already deleted"; first->set_explain_type(TRUE/* on_the_fly */); - Explain_select *qp_sel= new (output->mem_root)Explain_select; - qp_sel->select_id= first->select_number; - qp_sel->select_type= first->type; - qp_sel->message= msg; - output->add_node(qp_sel); - eu->add_select(qp_sel->select_id); + Explain_select *explain= new (output->mem_root)Explain_select; + explain->select_id= first->select_number; + explain->select_type= first->type; + explain->message= msg; + output->add_node(explain); + eu->add_select(explain->select_id); return 0; } diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 8bff5c640df..62d44f622ae 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -2369,7 +2369,7 @@ class Delete_plan; class SQL_SELECT; class Explain_query; -class QPF_update; +class Explain_update; /* Query plan of a single-table UPDATE. @@ -2399,7 +2399,7 @@ public: void set_impossible_where() { impossible_where= true; } void save_explain_data(Explain_query *query); - void save_explain_data_intern(Explain_query *query, QPF_update *qpf); + void save_explain_data_intern(Explain_query *query, Explain_update *eu); virtual ~Update_plan() {} Update_plan() : impossible_where(false), using_filesort(false) {} diff --git a/sql/sql_select.cc b/sql/sql_select.cc index c87470b5e37..c787d659e36 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -22481,7 +22481,7 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table, bool need_order, bool distinct, const char *message) { - Explain_node *qp_node; + Explain_node *explain_node; JOIN *join= this; /* Legacy: this code used to be a non-member function */ THD *thd=join->thd; const CHARSET_INFO *cs= system_charset_info; @@ -22497,7 +22497,7 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table, if (message) { Explain_select *xpl_sel; - qp_node= xpl_sel= new (output->mem_root) Explain_select; + explain_node= xpl_sel= new (output->mem_root) Explain_select; join->select_lex->set_explain_type(true); xpl_sel->select_id= join->select_lex->select_number; @@ -22514,7 +22514,7 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table, join->select_lex->master_unit()->derived->is_materialized_derived()) { Explain_select *xpl_sel; - qp_node= xpl_sel= new (output->mem_root) Explain_select; + explain_node= xpl_sel= new (output->mem_root) Explain_select; table_map used_tables=0; join->select_lex->set_explain_type(true); @@ -22562,16 +22562,16 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table, tab= pre_sort_join_tab; } - Explain_table_access *qpt= new (output->mem_root) Explain_table_access; - xpl_sel->add_table(qpt); - qpt->key.set(thd->mem_root, NULL, (uint)-1); - qpt->quick_info= NULL; + Explain_table_access *eta= new (output->mem_root) Explain_table_access; + xpl_sel->add_table(eta); + eta->key.set(thd->mem_root, NULL, (uint)-1); + eta->quick_info= NULL; /* id */ if (tab->bush_root_tab) - qpt->sjm_nest_select_id= select_id; + eta->sjm_nest_select_id= select_id; else - qpt->sjm_nest_select_id= 0; + eta->sjm_nest_select_id= 0; /* select_type */ xpl_sel->select_type= join->select_lex->type; @@ -22583,7 +22583,7 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table, int len= my_snprintf(table_name_buffer, sizeof(table_name_buffer)-1, "", table->derived_select_number); - qpt->table_name.copy(table_name_buffer, len, cs); + eta->table_name.copy(table_name_buffer, len, cs); } else if (tab->bush_children) { @@ -22593,12 +22593,12 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table, sizeof(table_name_buffer)-1, "", ctab->emb_sj_nest->sj_subq_pred->get_identifier()); - qpt->table_name.copy(table_name_buffer, len, cs); + eta->table_name.copy(table_name_buffer, len, cs); } else { TABLE_LIST *real_table= table->pos_in_table_list; - qpt->table_name.copy(real_table->alias, strlen(real_table->alias), cs); + eta->table_name.copy(real_table->alias, strlen(real_table->alias), cs); } /* "partitions" column */ @@ -22608,14 +22608,14 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table, if (!table->derived_select_number && (part_info= table->part_info)) { - make_used_partitions_str(part_info, &qpt->used_partitions); - qpt->used_partitions_set= true; + make_used_partitions_str(part_info, &eta->used_partitions); + eta->used_partitions_set= true; } else - qpt->used_partitions_set= false; + eta->used_partitions_set= false; #else /* just produce empty column if partitioning is not compiled in */ - qpt->used_partitions_set= false; + eta->used_partitions_set= false; #endif } @@ -22634,10 +22634,10 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table, else tab_type= tab->type == JT_ALL ? JT_RANGE : JT_HASH_RANGE; } - qpt->type= tab_type; + eta->type= tab_type; /* Build "possible_keys" value */ - append_possible_keys(&qpt->possible_keys_str, table, tab->keys); + append_possible_keys(&eta->possible_keys_str, table, tab->keys); /* Build "key", "key_len", and "ref" */ if (tab_type == JT_NEXT) @@ -22657,13 +22657,13 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table, */ if (tab->select && tab->select->quick && tab_type != JT_CONST) { - qpt->quick_info= new Explain_quick_select; - tab->select->quick->save_info(thd->mem_root, qpt->quick_info); + eta->quick_info= new Explain_quick_select; + tab->select->quick->save_info(thd->mem_root, eta->quick_info); } if (key_info) /* 'index' or 'ref' access */ { - qpt->key.set(thd->mem_root, key_info->name, key_len); + eta->key.set(thd->mem_root, key_info->name, key_len); if (tab->ref.key_parts && tab_type != JT_FT) { @@ -22686,7 +22686,7 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table, if (tab_type == JT_HASH_NEXT) /* full index scan + hash join */ { - qpt->hash_next_key.set(thd->mem_root, + eta->hash_next_key.set(thd->mem_root, table->key_info[tab->index].name, table->key_info[tab->index].key_length); } @@ -22695,11 +22695,11 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table, { if (key_info && tab_type != JT_NEXT) { - qpt->ref.copy(tmp4); - qpt->ref_set= true; + eta->ref.copy(tmp4); + eta->ref_set= true; } else - qpt->ref_set= false; + eta->ref_set= false; } else { @@ -22728,9 +22728,9 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table, } if (key_name_buf.length()) - qpt->key.set(thd->mem_root, key_name_buf.c_ptr_safe(), -1); + eta->key.set(thd->mem_root, key_name_buf.c_ptr_safe(), -1); } - qpt->ref_set= false; + eta->ref_set= false; } /* "rows" */ @@ -22738,15 +22738,15 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table, table_list->schema_table) { /* I_S tables have rows=extra=NULL */ - qpt->rows_set= false; - qpt->filtered_set= false; + eta->rows_set= false; + eta->filtered_set= false; } else { ha_rows examined_rows= tab->get_examined_rows(); - qpt->rows_set= true; - qpt->rows= examined_rows; + eta->rows_set= true; + eta->rows= examined_rows; /* "filtered" */ float f= 0.0; @@ -22759,8 +22759,8 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table, f= (float) (100.0 * pushdown_cond_selectivity); } set_if_smaller(f, 100.0); - qpt->filtered_set= true; - qpt->filtered= f; + eta->filtered_set= true; + eta->filtered= f; } /* Build "Extra" field and save it */ @@ -22774,16 +22774,16 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table, if (tab->info) { - qpt->push_extra(tab->info); + eta->push_extra(tab->info); } else if (tab->packed_info & TAB_INFO_HAVE_VALUE) { if (tab->packed_info & TAB_INFO_USING_INDEX) - qpt->push_extra(ET_USING_INDEX); + eta->push_extra(ET_USING_INDEX); if (tab->packed_info & TAB_INFO_USING_WHERE) - qpt->push_extra(ET_USING_WHERE); + eta->push_extra(ET_USING_WHERE); if (tab->packed_info & TAB_INFO_FULL_SCAN_ON_NULL) - qpt->push_extra(ET_FULL_SCAN_ON_NULL_KEY); + eta->push_extra(ET_FULL_SCAN_ON_NULL_KEY); } else { @@ -22795,23 +22795,23 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table, if (keyno != MAX_KEY && keyno == table->file->pushed_idx_cond_keyno && table->file->pushed_idx_cond) - qpt->push_extra(ET_USING_INDEX_CONDITION); + eta->push_extra(ET_USING_INDEX_CONDITION); else if (tab->cache_idx_cond) - qpt->push_extra(ET_USING_INDEX_CONDITION_BKA); + eta->push_extra(ET_USING_INDEX_CONDITION_BKA); if (quick_type == QUICK_SELECT_I::QS_TYPE_ROR_UNION || quick_type == QUICK_SELECT_I::QS_TYPE_ROR_INTERSECT || quick_type == QUICK_SELECT_I::QS_TYPE_INDEX_INTERSECT || quick_type == QUICK_SELECT_I::QS_TYPE_INDEX_MERGE) { - qpt->push_extra(ET_USING); + eta->push_extra(ET_USING); } if (tab->select) { if (tab->use_quick == 2) { - qpt->push_extra(ET_RANGE_CHECKED_FOR_EACH_RECORD); - qpt->range_checked_map= tab->keys; + eta->push_extra(ET_RANGE_CHECKED_FOR_EACH_RECORD); + eta->range_checked_map= tab->keys; } else if (tab->select->cond) { @@ -22823,7 +22823,7 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table, HA_MUST_USE_TABLE_CONDITION_PUSHDOWN)) && pushed_cond) { - qpt->push_extra(ET_USING_WHERE_WITH_PUSHED_CONDITION); + eta->push_extra(ET_USING_WHERE_WITH_PUSHED_CONDITION); /* psergey-todo: what to do? This was useful with NDB only. @@ -22835,7 +22835,7 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table, */ } else - qpt->push_extra(ET_USING_WHERE); + eta->push_extra(ET_USING_WHERE); } } if (table_list /* SJM bushes don't have table_list */ && @@ -22843,20 +22843,20 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table, table_list->schema_table->i_s_requested_object & OPTIMIZE_I_S_TABLE) { if (!table_list->table_open_method) - qpt->push_extra(ET_SKIP_OPEN_TABLE); + eta->push_extra(ET_SKIP_OPEN_TABLE); else if (table_list->table_open_method == OPEN_FRM_ONLY) - qpt->push_extra(ET_OPEN_FRM_ONLY); + eta->push_extra(ET_OPEN_FRM_ONLY); else - qpt->push_extra(ET_OPEN_FULL_TABLE); + eta->push_extra(ET_OPEN_FULL_TABLE); /* psergey-note: the following has a bug.*/ if (table_list->has_db_lookup_value && table_list->has_table_lookup_value) - qpt->push_extra(ET_SCANNED_0_DATABASES); + eta->push_extra(ET_SCANNED_0_DATABASES); else if (table_list->has_db_lookup_value || table_list->has_table_lookup_value) - qpt->push_extra(ET_SCANNED_1_DATABASE); + eta->push_extra(ET_SCANNED_1_DATABASE); else - qpt->push_extra(ET_SCANNED_ALL_DATABASES); + eta->push_extra(ET_SCANNED_ALL_DATABASES); } if (key_read) { @@ -22864,21 +22864,21 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table, { QUICK_GROUP_MIN_MAX_SELECT *qgs= (QUICK_GROUP_MIN_MAX_SELECT *) tab->select->quick; - qpt->push_extra(ET_USING_INDEX_FOR_GROUP_BY); - qpt->loose_scan_is_scanning= qgs->loose_scan_is_scanning(); + eta->push_extra(ET_USING_INDEX_FOR_GROUP_BY); + eta->loose_scan_is_scanning= qgs->loose_scan_is_scanning(); } else - qpt->push_extra(ET_USING_INDEX); + eta->push_extra(ET_USING_INDEX); } if (table->reginfo.not_exists_optimize) - qpt->push_extra(ET_NOT_EXISTS); + eta->push_extra(ET_NOT_EXISTS); if (quick_type == QUICK_SELECT_I::QS_TYPE_RANGE) { explain_append_mrr_info((QUICK_RANGE_SELECT*)(tab->select->quick), - &qpt->mrr_type); - if (qpt->mrr_type.length() > 0) - qpt->push_extra(ET_USING_MRR); + &eta->mrr_type); + if (eta->mrr_type.length() > 0) + eta->push_extra(ET_USING_MRR); } if (need_tmp_table) @@ -22893,23 +22893,23 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table, } if (distinct & test_all_bits(used_tables, join->select_list_used_tables)) - qpt->push_extra(ET_DISTINCT); + eta->push_extra(ET_DISTINCT); if (tab->loosescan_match_tab) { - qpt->push_extra(ET_LOOSESCAN); + eta->push_extra(ET_LOOSESCAN); } if (tab->first_weedout_table) - qpt->push_extra(ET_START_TEMPORARY); + eta->push_extra(ET_START_TEMPORARY); if (tab->check_weed_out_table) - qpt->push_extra(ET_END_TEMPORARY); + eta->push_extra(ET_END_TEMPORARY); else if (tab->do_firstmatch) { if (tab->do_firstmatch == /*join->join_tab*/ first_top_tab - 1) - qpt->push_extra(ET_FIRST_MATCH); + eta->push_extra(ET_FIRST_MATCH); else { - qpt->push_extra(ET_FIRST_MATCH); + eta->push_extra(ET_FIRST_MATCH); TABLE *prev_table=tab->do_firstmatch->table; if (prev_table->derived_select_number) { @@ -22918,10 +22918,10 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table, int len= my_snprintf(namebuf, sizeof(namebuf)-1, "", prev_table->derived_select_number); - qpt->firstmatch_table_name.append(namebuf, len); + eta->firstmatch_table_name.append(namebuf, len); } else - qpt->firstmatch_table_name.append(prev_table->pos_in_table_list->alias); + eta->firstmatch_table_name.append(prev_table->pos_in_table_list->alias); } } @@ -22929,15 +22929,15 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table, { if (tab->ref.cond_guards[part]) { - qpt->push_extra(ET_FULL_SCAN_ON_NULL_KEY); + eta->push_extra(ET_FULL_SCAN_ON_NULL_KEY); break; } } if (tab->cache) { - qpt->push_extra(ET_USING_JOIN_BUFFER); - tab->cache->save_explain_data(&qpt->bka_type); + eta->push_extra(ET_USING_JOIN_BUFFER); + tab->cache->save_explain_data(&eta->bka_type); } } @@ -22963,7 +22963,7 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table, if (!(unit->item && unit->item->eliminated) && // (1) (!unit->derived || unit->derived->is_materialized_derived())) // (2) { - qp_node->add_child(unit->first_select()->select_number); + explain_node->add_child(unit->first_select()->select_number); } } @@ -22995,12 +22995,12 @@ static void select_describe(JOIN *join, bool need_tmp_table, bool need_order, DBUG_ENTER("select_describe"); /* Update the QPF with latest values of using_temporary, using_filesort */ - Explain_select *qp; + Explain_select *explain_sel; uint select_nr= join->select_lex->select_number; - if ((qp= thd->lex->explain->get_select(select_nr))) + if ((explain_sel= thd->lex->explain->get_select(select_nr))) { - qp->using_temporary= need_tmp_table; - qp->using_filesort= need_order; + explain_sel->using_temporary= need_tmp_table; + explain_sel->using_filesort= need_order; } for (SELECT_LEX_UNIT *unit= join->select_lex->first_inner_unit();