summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/sql_select.cc11
-rw-r--r--sql/sql_select.h6
2 files changed, 14 insertions, 3 deletions
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 06a0ceaa69f..d69fb926de0 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -10643,10 +10643,15 @@ void JOIN::cleanup(bool full)
w/o tables: they don't have some members initialized and
WALK_OPTIMIZATION_TABS may not work correctly for them.
*/
- if (table_count)
+ enum enum_exec_or_opt tabs_kind;
+ if (first_breadth_first_tab(this, WALK_OPTIMIZATION_TABS))
+ tabs_kind= WALK_OPTIMIZATION_TABS;
+ else
+ tabs_kind= WALK_EXECUTION_TABS;
+ if (table_count)
{
- for (tab= first_breadth_first_tab(this, WALK_OPTIMIZATION_TABS); tab;
- tab= next_breadth_first_tab(this, WALK_OPTIMIZATION_TABS, tab))
+ for (tab= first_breadth_first_tab(this, tabs_kind); tab;
+ tab= next_breadth_first_tab(this, tabs_kind, tab))
{
tab->cleanup();
}
diff --git a/sql/sql_select.h b/sql/sql_select.h
index 47e5f0537b8..7168fd54024 100644
--- a/sql/sql_select.h
+++ b/sql/sql_select.h
@@ -1308,6 +1308,12 @@ public:
pre_sort_join_tab= NULL;
emb_sjm_nest= NULL;
sjm_lookup_tables= 0;
+ /*
+ The following is needed because JOIN::cleanup(true) may be called for
+ joins for which JOIN::optimize was aborted with an error before a proper
+ query plan was produced
+ */
+ table_access_tabs= NULL;
}
int prepare(Item ***rref_pointer_array, TABLE_LIST *tables, uint wind_num,