diff options
author | Sergey Petrunya <psergey@askmonty.org> | 2013-07-15 18:51:52 +0400 |
---|---|---|
committer | Sergey Petrunya <psergey@askmonty.org> | 2013-07-15 18:51:52 +0400 |
commit | 716a49a19e9a6fdd86f384917c8fdd6fdd0dd53f (patch) | |
tree | 525ec219024dc4f0a4acd96c3a3dee5245e21c44 | |
parent | e8b0b51966ae8b112c61650814af78530e8e7624 (diff) | |
download | mariadb-git-716a49a19e9a6fdd86f384917c8fdd6fdd0dd53f.tar.gz |
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
-rw-r--r-- | sql/sql_select.cc | 11 | ||||
-rw-r--r-- | sql/sql_select.h | 6 |
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, |