diff options
author | Roman Nozdrin <roman.nozdrin@mariadb.com> | 2019-06-20 00:31:51 +0300 |
---|---|---|
committer | Roman Nozdrin <roman.nozdrin@mariadb.com> | 2019-06-20 00:31:51 +0300 |
commit | 2a9c025a2064c090667285c57183dcc0de9d4d65 (patch) | |
tree | f4d7ce197f2a19590203a6ba7da21e90854253f3 | |
parent | 02979daab48d871e8c43a227b8f4462128439f17 (diff) | |
download | mariadb-git-10.4-drrtuy-MCOL-2178_2.tar.gz |
MDEV-XXX find_select_handler now tries its best to find a handlerton that10.4-drrtuy-MCOL-2178_2
is able to processes the whole query. find_select_handler traverses
all global tables for the purpose.
Select_handler now cleans up temporary table structures on dctor call.
-rw-r--r-- | sql/select_handler.cc | 2 | ||||
-rw-r--r-- | sql/sql_select.cc | 24 |
2 files changed, 15 insertions, 11 deletions
diff --git a/sql/select_handler.cc b/sql/select_handler.cc index f020d2f6b80..b364cb12341 100644 --- a/sql/select_handler.cc +++ b/sql/select_handler.cc @@ -45,6 +45,8 @@ Pushdown_select::Pushdown_select(SELECT_LEX *sel, select_handler *h) Pushdown_select::~Pushdown_select() { + if (handler->table) + free_tmp_table(handler->thd, handler->table); delete handler; select->select_h= NULL; } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 826026a51d7..3ff847b355a 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -1543,16 +1543,7 @@ int JOIN::optimize() { int res= 0; join_optimization_state init_state= optimization_state; - if (select_lex->pushdown_select) - { - if (!(select_options & SELECT_DESCRIBE)) - { - /* Prepare to execute the query pushed into a foreign engine */ - res= select_lex->pushdown_select->init(); - } - with_two_phase_optimization= false; - } - else if (optimization_state == JOIN::OPTIMIZATION_PHASE_1_DONE) + if (optimization_state == JOIN::OPTIMIZATION_PHASE_1_DONE) res= optimize_stage2(); else { @@ -1562,6 +1553,17 @@ int JOIN::optimize() optimization_state= JOIN::OPTIMIZATION_IN_PROGRESS; res= optimize_inner(); } + + if (select_lex->pushdown_select) + { + if (!(select_options & SELECT_DESCRIBE)) + { + /* Prepare to execute the query pushed into a foreign engine */ + res= select_lex->pushdown_select->init(); + } + with_two_phase_optimization= false; + } + if (!with_two_phase_optimization || init_state == JOIN::OPTIMIZATION_PHASE_1_DONE) { @@ -28494,7 +28496,7 @@ select_handler *SELECT_LEX::find_select_handler(THD *thd) return 0; if (master_unit()->outer_select()) return 0; - for (TABLE_LIST *tbl= join->tables_list; tbl; tbl= tbl->next_local) + for (TABLE_LIST *tbl= join->tables_list; tbl; tbl= tbl->next_global) { if (!tbl->table) continue; |