diff options
author | Sergey Petrunya <psergey@askmonty.org> | 2013-10-14 20:09:33 +0400 |
---|---|---|
committer | Sergey Petrunya <psergey@askmonty.org> | 2013-10-14 20:09:33 +0400 |
commit | 105e3ae6c93f57498fa6c504dfbb92203b0d1056 (patch) | |
tree | 8148f8bc8bbd717f5b4540e0ea8a7673a490fc00 /sql/sql_explain.h | |
parent | f67f8fd00fa6cf4bb38b10094060e6842a7d8daa (diff) | |
download | mariadb-git-105e3ae6c93f57498fa6c504dfbb92203b0d1056.tar.gz |
MDEV-3798: EXPLAIN UPDATE/DELETE
Update the SHOW EXPLAIN code to work with the
new architecture (part#1):
Before, SHOW EXPLAIN operated on real query plan structures,
which meant it had to check when SELECTs are created/deleted.
SELECTs would call apc_target->enable() when they got a query
plan and disable() when their query plan was deleted.
Now, Explain data structure becomes available at once (and we
call apc_target->enable()) and then it stays until it is deleted
(when that happens, we call apc_target->disable()).
Diffstat (limited to 'sql/sql_explain.h')
-rw-r--r-- | sql/sql_explain.h | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/sql/sql_explain.h b/sql/sql_explain.h index 2eb9e528a67..12621b88d23 100644 --- a/sql/sql_explain.h +++ b/sql/sql_explain.h @@ -221,10 +221,13 @@ class Explain_insert; class Explain_query : public Sql_alloc { public: - Explain_query(); + Explain_query(THD *thd); ~Explain_query(); + /* Add a new node */ void add_node(Explain_node *node); + void add_insert_plan(Explain_insert *insert_plan_arg); + void add_upd_del_plan(Explain_update *upd_del_plan_arg); /* This will return a select, or a union */ Explain_node *get_node(uint select_id); @@ -233,13 +236,7 @@ public: Explain_select *get_select(uint select_id); Explain_union *get_union(uint select_id); - - /* Explain_delete inherits from Explain_update */ - Explain_update *upd_del_plan; - - /* Query "plan" for INSERTs */ - Explain_insert *insert_plan; - + /* Produce a tabular EXPLAIN output */ int print_explain(select_result_sink *output, uint8 explain_flags); @@ -251,11 +248,22 @@ public: /* If true, at least part of EXPLAIN can be printed */ bool have_query_plan() { return insert_plan || upd_del_plan|| get_node(1) != NULL; } + + void query_plan_ready(); + MEM_ROOT *mem_root; private: + /* Explain_delete inherits from Explain_update */ + Explain_update *upd_del_plan; + + /* Query "plan" for INSERTs */ + Explain_insert *insert_plan; + Dynamic_array<Explain_union*> unions; Dynamic_array<Explain_select*> selects; + THD *thd; // for APC start/stop + bool apc_enabled; /* Debugging aid: count how many times add_node() was called. Ideally, it should be one, we currently allow O(1) query plan saves for each |