Commit 716a49a1 authored by Sergey Petrunya's avatar Sergey Petrunya

MDEV-4536, MDEV-4042

- Make JOIN::cleanup(true) also work correctly when the query is KILLed
  after join optimization was started but before a query plan was produced
parent e8b0b519
...@@ -10643,10 +10643,15 @@ void JOIN::cleanup(bool full) ...@@ -10643,10 +10643,15 @@ void JOIN::cleanup(bool full)
w/o tables: they don't have some members initialized and w/o tables: they don't have some members initialized and
WALK_OPTIMIZATION_TABS may not work correctly for them. 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; for (tab= first_breadth_first_tab(this, tabs_kind); tab;
tab= next_breadth_first_tab(this, WALK_OPTIMIZATION_TABS, tab)) tab= next_breadth_first_tab(this, tabs_kind, tab))
{ {
tab->cleanup(); tab->cleanup();
} }
......
...@@ -1308,6 +1308,12 @@ class JOIN :public Sql_alloc ...@@ -1308,6 +1308,12 @@ class JOIN :public Sql_alloc
pre_sort_join_tab= NULL; pre_sort_join_tab= NULL;
emb_sjm_nest= NULL; emb_sjm_nest= NULL;
sjm_lookup_tables= 0; 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, int prepare(Item ***rref_pointer_array, TABLE_LIST *tables, uint wind_num,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment