Code cleanup.
This commit is contained in:
parent
abf4a910f2
commit
ae6e95c498
@ -81,14 +81,13 @@ void QPF_query::add_node(QPF_node *node)
|
|||||||
QPF_select *sel= (QPF_select*)node;
|
QPF_select *sel= (QPF_select*)node;
|
||||||
if (sel->select_id == (int)UINT_MAX)
|
if (sel->select_id == (int)UINT_MAX)
|
||||||
{
|
{
|
||||||
//TODO this is a "fake select" from a UNION.
|
DBUG_ASSERT(0); // this is a "fake select" from a UNION.
|
||||||
DBUG_ASSERT(0);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
uint select_id= sel->select_id;
|
uint select_id= sel->select_id;
|
||||||
QPF_select *old_node;
|
QPF_select *old_node;
|
||||||
//DBUG_ASSERT(!get_select(select_id));
|
|
||||||
if (selects.elements() <= select_id)
|
if (selects.elements() <= select_id)
|
||||||
selects.resize(max(select_id+1, selects.elements()*2), NULL);
|
selects.resize(max(select_id+1, selects.elements()*2), NULL);
|
||||||
|
|
||||||
@ -115,7 +114,7 @@ int QPF_query::print_explain(select_result_sink *output,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Start printing from id=1
|
/* Start printing from node with id=1 */
|
||||||
QPF_node *node= get_node(1);
|
QPF_node *node= get_node(1);
|
||||||
return node->print_explain(this, output, explain_flags);
|
return node->print_explain(this, output, explain_flags);
|
||||||
}
|
}
|
||||||
@ -264,8 +263,6 @@ QPF_select::~QPF_select()
|
|||||||
int QPF_select::print_explain(QPF_query *query, select_result_sink *output,
|
int QPF_select::print_explain(QPF_query *query, select_result_sink *output,
|
||||||
uint8 explain_flags)
|
uint8 explain_flags)
|
||||||
{
|
{
|
||||||
//output->unit.offset_limit_cnt= 0;
|
|
||||||
|
|
||||||
if (message)
|
if (message)
|
||||||
{
|
{
|
||||||
List<Item> item_list;
|
List<Item> item_list;
|
||||||
@ -328,7 +325,6 @@ int QPF_table_access::print_explain(select_result_sink *output, uint8 explain_fl
|
|||||||
|
|
||||||
List<Item> item_list;
|
List<Item> item_list;
|
||||||
Item *item_null= new Item_null();
|
Item *item_null= new Item_null();
|
||||||
//const CHARSET_INFO *cs= system_charset_info;
|
|
||||||
|
|
||||||
if (sjm_nest_select_id)
|
if (sjm_nest_select_id)
|
||||||
select_id= sjm_nest_select_id;
|
select_id= sjm_nest_select_id;
|
||||||
|
@ -361,7 +361,7 @@ public:
|
|||||||
StringBuffer<32> used_partitions;
|
StringBuffer<32> used_partitions;
|
||||||
bool used_partitions_set;
|
bool used_partitions_set;
|
||||||
|
|
||||||
/* Empty strings means "NULL" will be printed */
|
/* Empty string means "NULL" will be printed */
|
||||||
StringBuffer<32> possible_keys_str;
|
StringBuffer<32> possible_keys_str;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -375,7 +375,8 @@ public:
|
|||||||
QPF_index_use key;
|
QPF_index_use key;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
when type==JT_HASH_NEXT, this stores the real index.
|
when type==JT_HASH_NEXT, 'key' stores the hash join pseudo-key.
|
||||||
|
hash_next_key stores the table's key.
|
||||||
*/
|
*/
|
||||||
QPF_index_use hash_next_key;
|
QPF_index_use hash_next_key;
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
invoked on a running DELETE statement.
|
invoked on a running DELETE statement.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void Delete_plan::save_query_plan_footprint(QPF_query *query)
|
void Delete_plan::save_qpf(QPF_query *query)
|
||||||
{
|
{
|
||||||
QPF_delete* qpf= new QPF_delete;
|
QPF_delete* qpf= new QPF_delete;
|
||||||
|
|
||||||
@ -63,22 +63,22 @@ void Delete_plan::save_query_plan_footprint(QPF_query *query)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
qpf->deleting_all_rows= false;
|
qpf->deleting_all_rows= false;
|
||||||
Update_plan::save_query_plan_footprint_intern(query, qpf);
|
Update_plan::save_qpf_intern(query, qpf);
|
||||||
}
|
}
|
||||||
|
|
||||||
query->upd_del_plan= qpf;
|
query->upd_del_plan= qpf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Update_plan::save_query_plan_footprint(QPF_query *query)
|
void Update_plan::save_qpf(QPF_query *query)
|
||||||
{
|
{
|
||||||
QPF_update* qpf= new QPF_update;
|
QPF_update* qpf= new QPF_update;
|
||||||
save_query_plan_footprint_intern(query, qpf);
|
save_qpf_intern(query, qpf);
|
||||||
query->upd_del_plan= qpf;
|
query->upd_del_plan= qpf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Update_plan::save_query_plan_footprint_intern(QPF_query *query, QPF_update *qpf)
|
void Update_plan::save_qpf_intern(QPF_query *query, QPF_update *qpf)
|
||||||
{
|
{
|
||||||
qpf->select_type= "SIMPLE";
|
qpf->select_type= "SIMPLE";
|
||||||
qpf->table_name.append(table->pos_in_table_list->alias);
|
qpf->table_name.append(table->pos_in_table_list->alias);
|
||||||
@ -116,7 +116,6 @@ void Update_plan::save_query_plan_footprint_intern(QPF_query *query, QPF_update
|
|||||||
qpf->using_where= test(select && select->cond);
|
qpf->using_where= test(select && select->cond);
|
||||||
qpf->using_filesort= using_filesort;
|
qpf->using_filesort= using_filesort;
|
||||||
|
|
||||||
//using_filesort is already set
|
|
||||||
make_possible_keys_line(table, possible_keys, &qpf->possible_keys_line);
|
make_possible_keys_line(table, possible_keys, &qpf->possible_keys_line);
|
||||||
|
|
||||||
/* Calculate key_len */
|
/* Calculate key_len */
|
||||||
@ -141,6 +140,7 @@ void Update_plan::save_query_plan_footprint_intern(QPF_query *query, QPF_update
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool skip= updating_a_view;
|
bool skip= updating_a_view;
|
||||||
|
|
||||||
/* Save subquery children */
|
/* Save subquery children */
|
||||||
for (SELECT_LEX_UNIT *unit= select_lex->first_inner_unit();
|
for (SELECT_LEX_UNIT *unit= select_lex->first_inner_unit();
|
||||||
unit;
|
unit;
|
||||||
@ -157,11 +157,6 @@ void Update_plan::save_query_plan_footprint_intern(QPF_query *query, QPF_update
|
|||||||
*/
|
*/
|
||||||
if (!(unit->item && unit->item->eliminated))
|
if (!(unit->item && unit->item->eliminated))
|
||||||
qpf->add_child(unit->first_select()->select_number);
|
qpf->add_child(unit->first_select()->select_number);
|
||||||
|
|
||||||
//TODO: temporary?:
|
|
||||||
// A: yes. optimizing children subqueries has caused them to save QPFs,
|
|
||||||
// automatically.
|
|
||||||
//unit->save_qpf(query);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -423,7 +418,7 @@ bool mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds,
|
|||||||
if (thd->lex->describe)
|
if (thd->lex->describe)
|
||||||
goto exit_without_my_ok;
|
goto exit_without_my_ok;
|
||||||
|
|
||||||
query_plan.save_query_plan_footprint(thd->lex->query_plan_footprint);
|
query_plan.save_qpf(thd->lex->query_plan_footprint);
|
||||||
thd->apc_target.enable();
|
thd->apc_target.enable();
|
||||||
|
|
||||||
DBUG_EXECUTE_IF("show_explain_probe_delete_exec_start",
|
DBUG_EXECUTE_IF("show_explain_probe_delete_exec_start",
|
||||||
@ -656,7 +651,7 @@ cleanup:
|
|||||||
|
|
||||||
/* Special exits */
|
/* Special exits */
|
||||||
exit_without_my_ok:
|
exit_without_my_ok:
|
||||||
query_plan.save_query_plan_footprint(thd->lex->query_plan_footprint);
|
query_plan.save_qpf(thd->lex->query_plan_footprint);
|
||||||
|
|
||||||
select_send *result2;
|
select_send *result2;
|
||||||
if (!(result2= new select_send()))
|
if (!(result2= new select_send()))
|
||||||
|
@ -2397,8 +2397,8 @@ public:
|
|||||||
/* Set this plan to be a plan to do nothing because of impossible WHRE*/
|
/* Set this plan to be a plan to do nothing because of impossible WHRE*/
|
||||||
void set_impossible_where() { impossible_where= true; }
|
void set_impossible_where() { impossible_where= true; }
|
||||||
|
|
||||||
void save_query_plan_footprint(QPF_query *query);
|
void save_qpf(QPF_query *query);
|
||||||
void save_query_plan_footprint_intern(QPF_query *query, QPF_update *qpf);
|
void save_qpf_intern(QPF_query *query, QPF_update *qpf);
|
||||||
virtual ~Update_plan() {}
|
virtual ~Update_plan() {}
|
||||||
|
|
||||||
Update_plan() : impossible_where(false), using_filesort(false) {}
|
Update_plan() : impossible_where(false), using_filesort(false) {}
|
||||||
@ -2422,7 +2422,7 @@ public:
|
|||||||
table_rows= rows_arg;
|
table_rows= rows_arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void save_query_plan_footprint(QPF_query *query);
|
void save_qpf(QPF_query *query);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -22517,8 +22517,6 @@ int JOIN::save_qpf(QPF_query *output, bool need_tmp_table, bool need_order,
|
|||||||
bool distinct, const char *message)
|
bool distinct, const char *message)
|
||||||
{
|
{
|
||||||
QPF_node *qp_node;
|
QPF_node *qp_node;
|
||||||
const bool on_the_fly= true;
|
|
||||||
|
|
||||||
JOIN *join= this; /* Legacy: this code used to be a non-member function */
|
JOIN *join= this; /* Legacy: this code used to be a non-member function */
|
||||||
THD *thd=join->thd;
|
THD *thd=join->thd;
|
||||||
const CHARSET_INFO *cs= system_charset_info;
|
const CHARSET_INFO *cs= system_charset_info;
|
||||||
@ -22535,7 +22533,7 @@ int JOIN::save_qpf(QPF_query *output, bool need_tmp_table, bool need_order,
|
|||||||
{
|
{
|
||||||
QPF_select *qp_sel;
|
QPF_select *qp_sel;
|
||||||
qp_node= qp_sel= new (output->mem_root) QPF_select;
|
qp_node= qp_sel= new (output->mem_root) QPF_select;
|
||||||
join->select_lex->set_explain_type(on_the_fly);
|
join->select_lex->set_explain_type(true);
|
||||||
|
|
||||||
qp_sel->select_id= join->select_lex->select_number;
|
qp_sel->select_id= join->select_lex->select_number;
|
||||||
qp_sel->select_type= join->select_lex->type;
|
qp_sel->select_type= join->select_lex->type;
|
||||||
@ -22554,10 +22552,7 @@ int JOIN::save_qpf(QPF_query *output, bool need_tmp_table, bool need_order,
|
|||||||
qp_node= qp_sel= new (output->mem_root) QPF_select;
|
qp_node= qp_sel= new (output->mem_root) QPF_select;
|
||||||
table_map used_tables=0;
|
table_map used_tables=0;
|
||||||
|
|
||||||
if (on_the_fly)
|
join->select_lex->set_explain_type(true);
|
||||||
join->select_lex->set_explain_type(on_the_fly);
|
|
||||||
|
|
||||||
//bool printing_materialize_nest= FALSE;
|
|
||||||
uint select_id= join->select_lex->select_number;
|
uint select_id= join->select_lex->select_number;
|
||||||
|
|
||||||
qp_sel->select_id= join->select_lex->select_number;
|
qp_sel->select_id= join->select_lex->select_number;
|
||||||
@ -22568,13 +22563,6 @@ int JOIN::save_qpf(QPF_query *output, bool need_tmp_table, bool need_order,
|
|||||||
for (JOIN_TAB *tab= first_breadth_first_tab(join, WALK_OPTIMIZATION_TABS); tab;
|
for (JOIN_TAB *tab= first_breadth_first_tab(join, WALK_OPTIMIZATION_TABS); tab;
|
||||||
tab= next_breadth_first_tab(join, WALK_OPTIMIZATION_TABS, tab))
|
tab= next_breadth_first_tab(join, WALK_OPTIMIZATION_TABS, tab))
|
||||||
{
|
{
|
||||||
if (tab->bush_root_tab)
|
|
||||||
{
|
|
||||||
JOIN_TAB *first_sibling= tab->bush_root_tab->bush_children->start;
|
|
||||||
select_id= first_sibling->emb_sj_nest->sj_subq_pred->get_identifier();
|
|
||||||
//printing_materialize_nest= TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
TABLE *table=tab->table;
|
TABLE *table=tab->table;
|
||||||
TABLE_LIST *table_list= tab->table->pos_in_table_list;
|
TABLE_LIST *table_list= tab->table->pos_in_table_list;
|
||||||
char buff4[512];
|
char buff4[512];
|
||||||
@ -22615,9 +22603,6 @@ int JOIN::save_qpf(QPF_query *output, bool need_tmp_table, bool need_order,
|
|||||||
qpt->sjm_nest_select_id= 0;
|
qpt->sjm_nest_select_id= 0;
|
||||||
|
|
||||||
/* select_type */
|
/* select_type */
|
||||||
//const char* stype= printing_materialize_nest? "MATERIALIZED" :
|
|
||||||
// join->select_lex->type;
|
|
||||||
//item_list.push_back(new Item_string(stype, strlen(stype), cs));
|
|
||||||
qp_sel->select_type= join->select_lex->type;
|
qp_sel->select_type= join->select_lex->type;
|
||||||
|
|
||||||
/* table */
|
/* table */
|
||||||
@ -22684,8 +22669,6 @@ int JOIN::save_qpf(QPF_query *output, bool need_tmp_table, bool need_order,
|
|||||||
append_possible_keys(&qpt->possible_keys_str, table, tab->keys);
|
append_possible_keys(&qpt->possible_keys_str, table, tab->keys);
|
||||||
|
|
||||||
/* Build "key", "key_len", and "ref" */
|
/* Build "key", "key_len", and "ref" */
|
||||||
|
|
||||||
// tmp4 holds ref
|
|
||||||
if (tab_type == JT_NEXT)
|
if (tab_type == JT_NEXT)
|
||||||
{
|
{
|
||||||
key_info= table->key_info+tab->index;
|
key_info= table->key_info+tab->index;
|
||||||
|
@ -500,7 +500,7 @@ int mysql_update(THD *thd,
|
|||||||
if (thd->lex->describe)
|
if (thd->lex->describe)
|
||||||
goto exit_without_my_ok;
|
goto exit_without_my_ok;
|
||||||
|
|
||||||
query_plan.save_query_plan_footprint(thd->lex->query_plan_footprint);
|
query_plan.save_qpf(thd->lex->query_plan_footprint);
|
||||||
thd->apc_target.enable();
|
thd->apc_target.enable();
|
||||||
apc_target_enabled= true;
|
apc_target_enabled= true;
|
||||||
DBUG_EXECUTE_IF("show_explain_probe_update_exec_start",
|
DBUG_EXECUTE_IF("show_explain_probe_update_exec_start",
|
||||||
@ -1031,10 +1031,9 @@ err:
|
|||||||
|
|
||||||
exit_without_my_ok:
|
exit_without_my_ok:
|
||||||
DBUG_ASSERT(!apc_target_enabled);
|
DBUG_ASSERT(!apc_target_enabled);
|
||||||
query_plan.save_query_plan_footprint(thd->lex->query_plan_footprint);
|
query_plan.save_qpf(thd->lex->query_plan_footprint);
|
||||||
|
|
||||||
select_send *result;
|
select_send *result;
|
||||||
//bool printed_anything;
|
|
||||||
if (!(result= new select_send()))
|
if (!(result= new select_send()))
|
||||||
return 1; /* purecov: inspected */
|
return 1; /* purecov: inspected */
|
||||||
List<Item> dummy; /* note: looked in 5.6 and they too use a dummy list like this */
|
List<Item> dummy; /* note: looked in 5.6 and they too use a dummy list like this */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user