diff options
Diffstat (limited to 'sql/item_subselect.cc')
-rw-r--r-- | sql/item_subselect.cc | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 56bd8c75a20..5cf585e1a56 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -1911,18 +1911,22 @@ int subselect_single_select_engine::exec() } if (!select_lex->uncacheable && thd->lex->describe && !(join->select_options & SELECT_DESCRIBE) && - join->need_tmp && item->const_item()) + join->need_tmp) { - /* - Force join->join_tmp creation, because this subquery will be replaced - by a simple select from the materialization temp table by optimize() - called by EXPLAIN and we need to preserve the initial query structure - so we can display it. - */ - select_lex->uncacheable|= UNCACHEABLE_EXPLAIN; - select_lex->master_unit()->uncacheable|= UNCACHEABLE_EXPLAIN; - if (join->init_save_join_tab()) - DBUG_RETURN(1); /* purecov: inspected */ + item->update_used_tables(); + if (item->const_item()) + { + /* + Force join->join_tmp creation, because this subquery will be replaced + by a simple select from the materialization temp table by optimize() + called by EXPLAIN and we need to preserve the initial query structure + so we can display it. + */ + select_lex->uncacheable|= UNCACHEABLE_EXPLAIN; + select_lex->master_unit()->uncacheable|= UNCACHEABLE_EXPLAIN; + if (join->init_save_join_tab()) + DBUG_RETURN(1); /* purecov: inspected */ + } } if (item->engine_changed) { |