summaryrefslogtreecommitdiff
path: root/sql/sql_lex.cc
diff options
context:
space:
mode:
authorSergey Petrunya <psergey@askmonty.org>2011-08-23 19:28:32 +0400
committerSergey Petrunya <psergey@askmonty.org>2011-08-23 19:28:32 +0400
commit7e66213444a5af73879b57ad0b5bd7476b5c6f4d (patch)
tree6939d6b4b4cea99971b19fd7ad97e8096ad26ebf /sql/sql_lex.cc
parentd2206ad14920e85907c965256e1ce061633c36ee (diff)
downloadmariadb-git-7e66213444a5af73879b57ad0b5bd7476b5c6f4d.tar.gz
MWL#182: Explain running statements
First code - "Asynchronous procedure call" system - new THD::check_killed() that serves APC request is called from within most important loops - EXPLAIN code is now able to generate EXPLAIN output on-the-fly [incomplete] Parts that are still missing: - put THD::check_killed() call into every loop where we could spend significant amount of time - Make sure EXPLAIN code works for group-by queries that replace JOIN::join_tab with make_simple_join() and other such cases. - User interface: what error code to use, where to get timeout settings from, etc.
Diffstat (limited to 'sql/sql_lex.cc')
-rw-r--r--sql/sql_lex.cc34
1 files changed, 34 insertions, 0 deletions
diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc
index 021e7a3b5e8..ae9c11c47e2 100644
--- a/sql/sql_lex.cc
+++ b/sql/sql_lex.cc
@@ -3623,6 +3623,40 @@ bool st_select_lex::save_prep_leaf_tables(THD *thd)
}
+int st_select_lex::print_explain(select_result_sink *output)
+{
+ if (join && join->optimized == 2)
+ {
+ //psergey-TODO: any?
+ return join->print_explain(output, TRUE,
+ FALSE, // need_tmp_table,
+ FALSE, // bool need_order,
+ FALSE, // bool distinct,
+ NULL); //const char *message
+ }
+ else
+ {
+ DBUG_ASSERT(0);
+ /* produce "not yet optimized" line */
+ }
+ return 0;
+}
+
+
+int st_select_lex_unit::print_explain(select_result_sink *output)
+{
+ int res= 0;
+ SELECT_LEX *first= first_select();
+
+ for (SELECT_LEX *sl= first; sl; sl= sl->next_select())
+ {
+ if ((res= sl->print_explain(output)))
+ break;
+ }
+ return res;
+}
+
+
/**
A routine used by the parser to decide whether we are specifying a full
partitioning or if only partitions to add or to split.