diff options
author | Monty <monty@mariadb.org> | 2014-08-29 14:07:43 +0300 |
---|---|---|
committer | Sergey Vojtovich <svoj@mariadb.org> | 2014-12-05 11:01:51 +0400 |
commit | 78564373fee5e6cccf144b11bc60b0876b4bbd0b (patch) | |
tree | b58780d298efdbceee041e5c07d030e500ec64cf /sql/sql_explain.cc | |
parent | 3392278c869a9594f13a0b956d34efb600ab0ed0 (diff) | |
download | mariadb-git-78564373fee5e6cccf144b11bc60b0876b4bbd0b.tar.gz |
my_alloc.cmariadb-10.1.2
- Changed 0x%lx -> %p
array.c:
- Static (preallocated) buffer can now be anywhere
my_sys.h
- Define MY_INIT_BUFFER_USED
sql_delete.cc & sql_lex.cc
- Use memroot when allocating classes (avoids call to current_thd)
sql_explain.h:
- Use preallocated buffers
sql_explain.cc:
- Use preallocated buffers and memroot
sql_select.cc:
- Use multi_alloc_root() instead of many alloc_root()
- Update calls to Explain
Diffstat (limited to 'sql/sql_explain.cc')
-rw-r--r-- | sql/sql_explain.cc | 34 |
1 files changed, 26 insertions, 8 deletions
diff --git a/sql/sql_explain.cc b/sql/sql_explain.cc index 0ad6a4d89ea..1bfcc1156d3 100644 --- a/sql/sql_explain.cc +++ b/sql/sql_explain.cc @@ -27,10 +27,11 @@ const char * STR_DELETING_ALL_ROWS= "Deleting all rows"; const char * STR_IMPOSSIBLE_WHERE= "Impossible WHERE"; const char * STR_NO_ROWS_AFTER_PRUNING= "No matching rows after partition pruning"; -Explain_query::Explain_query(THD *thd_arg) : - upd_del_plan(NULL), insert_plan(NULL), thd(thd_arg), apc_enabled(false) +Explain_query::Explain_query(THD *thd_arg, MEM_ROOT *root) : + mem_root(root), upd_del_plan(NULL), insert_plan(NULL), + unions(root), selects(root), thd(thd_arg), apc_enabled(false), + operations(0) { - operations= 0; } @@ -140,7 +141,7 @@ int Explain_query::send_explain(THD *thd) select_result *result; LEX *lex= thd->lex; - if (!(result= new select_send()) || + if (!(result= new (thd->mem_root) select_send()) || thd->send_explain_fields(result, lex->describe, lex->analyze_stmt)) return 1; @@ -225,7 +226,8 @@ bool print_explain_for_slow_log(LEX *lex, THD *thd, String *str) Return tabular EXPLAIN output as a text string */ -bool Explain_query::print_explain_str(THD *thd, String *out_str, bool is_analyze) +bool Explain_query::print_explain_str(THD *thd, String *out_str, + bool is_analyze) { List<Item> fields; thd->make_explain_field_list(fields, thd->lex->describe, is_analyze); @@ -551,6 +553,20 @@ int Explain_node::print_explain_for_children(Explain_query *query, return 0; } +bool Explain_basic_join::add_table(Explain_table_access *tab, Explain_query *query) +{ + if (!join_tabs) + { + n_join_tabs= 0; + if (!(join_tabs= ((Explain_table_access**) + alloc_root(query->mem_root, + sizeof(Explain_table_access*) * + MAX_TABLES)))) + return true; + } + join_tabs[n_join_tabs++]= tab; + return false; +} /* This tells whether a child subquery should be printed in JSON output. @@ -609,7 +625,6 @@ Explain_basic_join::~Explain_basic_join() { for (uint i= 0; i< n_join_tabs; i++) delete join_tabs[i]; - my_free(join_tabs); } } @@ -1895,9 +1910,12 @@ void delete_explain_query(LEX *lex) void create_explain_query(LEX *lex, MEM_ROOT *mem_root) { DBUG_ASSERT(!lex->explain); - lex->explain= new Explain_query(lex->thd); + DBUG_ENTER("create_explain_query"); + + lex->explain= new (mem_root) Explain_query(lex->thd, mem_root); DBUG_ASSERT(mem_root == current_thd->mem_root); - lex->explain->mem_root= mem_root; + + DBUG_VOID_RETURN; } void create_explain_query_if_not_exists(LEX *lex, MEM_ROOT *mem_root) |