summaryrefslogtreecommitdiff
path: root/sql/sql_select.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_select.cc')
-rw-r--r--sql/sql_select.cc7
1 files changed, 5 insertions, 2 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 0a7cd0f7338..ba9933a3d15 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -1050,7 +1050,7 @@ JOIN::optimize()
}
}
- if (select_lex->master_unit()->uncacheable)
+ if (thd->lex->subqueries)
{
if (!(tmp_join= (JOIN*)thd->alloc(sizeof(JOIN))))
DBUG_RETURN(-1);
@@ -5702,7 +5702,9 @@ JOIN::join_free(bool full)
JOIN_TAB *tab,*end;
DBUG_ENTER("JOIN::join_free");
- full= full || !select_lex->uncacheable;
+ full= full || (!select_lex->uncacheable &&
+ !thd->lex->subqueries &&
+ !thd->lex->describe); // do not cleanup too early on EXPLAIN
if (table)
{
@@ -5731,6 +5733,7 @@ JOIN::join_free(bool full)
for (tab= join_tab, end= tab+tables; tab != end; tab++)
tab->cleanup();
table= 0;
+ tables= 0;
}
else
{