Commit 6a7f8af3 authored by Sergey Petrunya's avatar Sergey Petrunya

MDEV-3798: EXPLAIN UPDATE/DELETE

- Address review feedback: rename files
parent fedf769f
...@@ -99,7 +99,7 @@ SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc ...@@ -99,7 +99,7 @@ SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc
../sql/sql_expression_cache.cc ../sql/sql_expression_cache.cc
../sql/my_apc.cc ../sql/my_apc.h ../sql/my_apc.cc ../sql/my_apc.h
../sql/rpl_gtid.cc ../sql/rpl_gtid.cc
../sql/opt_qpf.cc ../sql/opt_qpf.h ../sql/sql_explain.cc ../sql/sql_explain.h
${GEN_SOURCES} ${GEN_SOURCES}
${MYSYS_LIBWRAP_SOURCE} ${MYSYS_LIBWRAP_SOURCE}
) )
......
...@@ -80,7 +80,7 @@ SET (SQL_SOURCE ...@@ -80,7 +80,7 @@ SET (SQL_SOURCE
sql_reload.cc sql_reload.cc
# added in MariaDB: # added in MariaDB:
opt_qpf.h opt_qpf.cc sql_explain.h sql_explain.cc
sql_lifo_buffer.h sql_join_cache.h sql_join_cache.cc sql_lifo_buffer.h sql_join_cache.h sql_join_cache.cc
create_options.cc multi_range_read.cc create_options.cc multi_range_read.cc
opt_index_cond_pushdown.cc opt_subselect.cc opt_index_cond_pushdown.cc opt_subselect.cc
......
...@@ -3516,14 +3516,14 @@ bool st_select_lex::optimize_unflattened_subqueries(bool const_only) ...@@ -3516,14 +3516,14 @@ bool st_select_lex::optimize_unflattened_subqueries(bool const_only)
inner_join->select_options= save_options; inner_join->select_options= save_options;
un->thd->lex->current_select= save_select; un->thd->lex->current_select= save_select;
Explain_query *qpf; Explain_query *eq;
if ((qpf= inner_join->thd->lex->explain)) if ((eq= inner_join->thd->lex->explain))
{ {
Explain_select *qp_sel; Explain_select *expl_sel;
if ((qp_sel= qpf->get_select(inner_join->select_lex->select_number))) if ((expl_sel= eq->get_select(inner_join->select_lex->select_number)))
{ {
sl->set_explain_type(TRUE); sl->set_explain_type(TRUE);
qp_sel->select_type= sl->type; expl_sel->select_type= sl->type;
} }
} }
......
...@@ -2328,14 +2328,6 @@ void join_save_qpf(JOIN *join) ...@@ -2328,14 +2328,6 @@ void join_save_qpf(JOIN *join)
void JOIN::exec() void JOIN::exec()
{ {
/*
Enable SHOW EXPLAIN only if we're in the top-level query.
*/
/*
psergey: we can produce SHOW explain at this point. This means, we're ready
to save the query plan.
*/
thd->apc_target.enable(); thd->apc_target.enable();
DBUG_EXECUTE_IF("show_explain_probe_join_exec_start", DBUG_EXECUTE_IF("show_explain_probe_join_exec_start",
if (dbug_user_var_equals_int(thd, if (dbug_user_var_equals_int(thd,
...@@ -2343,7 +2335,6 @@ void JOIN::exec() ...@@ -2343,7 +2335,6 @@ void JOIN::exec()
select_lex->select_number)) select_lex->select_number))
dbug_serve_apcs(thd, 1); dbug_serve_apcs(thd, 1);
); );
exec_inner(); exec_inner();
if (!exec_saved_explain) if (!exec_saved_explain)
...@@ -22505,15 +22496,15 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table, ...@@ -22505,15 +22496,15 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table,
if (message) if (message)
{ {
Explain_select *qp_sel; Explain_select *xpl_sel;
qp_node= qp_sel= new (output->mem_root) Explain_select; qp_node= xpl_sel= new (output->mem_root) Explain_select;
join->select_lex->set_explain_type(true); join->select_lex->set_explain_type(true);
qp_sel->select_id= join->select_lex->select_number; xpl_sel->select_id= join->select_lex->select_number;
qp_sel->select_type= join->select_lex->type; xpl_sel->select_type= join->select_lex->type;
qp_sel->message= message; xpl_sel->message= message;
/* Setting qp_sel->message means that all other members are invalid */ /* Setting xpl_sel->message means that all other members are invalid */
output->add_node(qp_sel); output->add_node(xpl_sel);
} }
else if (join->select_lex == join->unit->fake_select_lex) else if (join->select_lex == join->unit->fake_select_lex)
{ {
...@@ -22522,13 +22513,13 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table, ...@@ -22522,13 +22513,13 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table,
else if (!join->select_lex->master_unit()->derived || else if (!join->select_lex->master_unit()->derived ||
join->select_lex->master_unit()->derived->is_materialized_derived()) join->select_lex->master_unit()->derived->is_materialized_derived())
{ {
Explain_select *qp_sel; Explain_select *xpl_sel;
qp_node= qp_sel= new (output->mem_root) Explain_select; qp_node= xpl_sel= new (output->mem_root) Explain_select;
table_map used_tables=0; table_map used_tables=0;
join->select_lex->set_explain_type(true); join->select_lex->set_explain_type(true);
qp_sel->select_id= join->select_lex->select_number; xpl_sel->select_id= join->select_lex->select_number;
qp_sel->select_type= join->select_lex->type; xpl_sel->select_type= join->select_lex->type;
JOIN_TAB* const first_top_tab= first_breadth_first_tab(join, WALK_OPTIMIZATION_TABS); JOIN_TAB* const first_top_tab= first_breadth_first_tab(join, WALK_OPTIMIZATION_TABS);
...@@ -22572,7 +22563,7 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table, ...@@ -22572,7 +22563,7 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table,
} }
Explain_table_access *qpt= new (output->mem_root) Explain_table_access; Explain_table_access *qpt= new (output->mem_root) Explain_table_access;
qp_sel->add_table(qpt); xpl_sel->add_table(qpt);
qpt->key.set(thd->mem_root, NULL, (uint)-1); qpt->key.set(thd->mem_root, NULL, (uint)-1);
qpt->quick_info= NULL; qpt->quick_info= NULL;
...@@ -22583,7 +22574,7 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table, ...@@ -22583,7 +22574,7 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table,
qpt->sjm_nest_select_id= 0; qpt->sjm_nest_select_id= 0;
/* select_type */ /* select_type */
qp_sel->select_type= join->select_lex->type; xpl_sel->select_type= join->select_lex->type;
/* table */ /* table */
if (table->derived_select_number) if (table->derived_select_number)
...@@ -22893,12 +22884,12 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table, ...@@ -22893,12 +22884,12 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table,
if (need_tmp_table) if (need_tmp_table)
{ {
need_tmp_table=0; need_tmp_table=0;
qp_sel->using_temporary= true; xpl_sel->using_temporary= true;
} }
if (need_order) if (need_order)
{ {
need_order=0; need_order=0;
qp_sel->using_filesort= true; xpl_sel->using_filesort= true;
} }
if (distinct & test_all_bits(used_tables, if (distinct & test_all_bits(used_tables,
join->select_list_used_tables)) join->select_list_used_tables))
...@@ -22956,7 +22947,7 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table, ...@@ -22956,7 +22947,7 @@ int JOIN::save_explain_data(Explain_query *output, bool need_tmp_table,
// For next iteration // For next iteration
used_tables|=table->map; used_tables|=table->map;
} }
output->add_node(qp_sel); output->add_node(xpl_sel);
} }
for (SELECT_LEX_UNIT *unit= join->select_lex->first_inner_unit(); for (SELECT_LEX_UNIT *unit= join->select_lex->first_inner_unit();
......
...@@ -198,7 +198,7 @@ int rr_sequential(READ_RECORD *info); ...@@ -198,7 +198,7 @@ int rr_sequential(READ_RECORD *info);
int rr_sequential_and_unpack(READ_RECORD *info); int rr_sequential_and_unpack(READ_RECORD *info);
#include "opt_qpf.h" #include "sql_explain.h"
/************************************************************************************** /**************************************************************************************
* New EXPLAIN structures END * New EXPLAIN structures END
......
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