summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Nozdrin <roman.nozdrin@mariadb.com>2019-06-20 00:31:51 +0300
committerRoman Nozdrin <roman.nozdrin@mariadb.com>2019-08-14 21:38:45 +0300
commit891f3d82ce541bb48804f79b2f1041c55428c849 (patch)
treebcc2e0390c0fc997e515053853b9b72093126f59
parent1d15a28e52e41fae0847284089b2073ab33162a5 (diff)
downloadmariadb-git-bb-10.4-MDEV-19831.tar.gz
MDEV-19831 find_select_handler() now tries its best to find a handlerton thatbb-10.4-MDEV-19831
is able to processes the whole query. For that it traverses tables from subqueries. Select_handler now cleans up temporary table structures on dctor call. Enable outer to inner JOIN rewrites for smart engine Select handler.
-rw-r--r--sql/select_handler.cc2
-rw-r--r--sql/sql_select.cc24
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 e79e96bf210..c526402fd71 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1570,16 +1570,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
{
@@ -1589,6 +1580,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)
{
@@ -28551,7 +28553,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;