From 716091e2a058644b81755ec3f3b1f736b0c84782 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Wed, 16 Feb 2011 13:26:27 +0300 Subject: [PATCH] Post-merge fixes part 4 --- sql/sql_join_cache.cc | 2 +- sql/sql_select.cc | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/sql/sql_join_cache.cc b/sql/sql_join_cache.cc index 55b84077c26..fbbcf395980 100644 --- a/sql/sql_join_cache.cc +++ b/sql/sql_join_cache.cc @@ -923,7 +923,7 @@ int JOIN_CACHE::alloc_buffer() //psergey-merge: for (tab= join->join_tab+join->const_tables; tab <= join_tab; tab++) // for (tab= cache->join_tab-cache->tables; tab < cache->join_tab ; tab++) // (fixed) - for (tab= join->join_tab + join->const_tables; tab!= join_tab; + for (tab= /*join->join_tab + join->const_tables*/ start_tab; tab!= join_tab; tab= next_linear_tab(join, tab, FALSE)) { cache= tab->cache; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index db617cde353..31f9abfcf89 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -8429,10 +8429,12 @@ void check_join_cache_usage_for_tables(JOIN *join, ulonglong options, if (!(tab >= first_sjm_table && tab < last_sjm_table)) tab->first_sjm_sibling= NULL; #endif + JOIN_TAB *prev_tab; +restart: tab->icp_other_tables_ok= TRUE; tab->idx_cond_fact_out= TRUE; - JOIN_TAB *prev_tab= tab - 1; + prev_tab= tab - 1; if ((tab->bush_root_tab && tab->bush_root_tab->bush_children->start == tab)) prev_tab= NULL; @@ -8450,11 +8452,20 @@ void check_join_cache_usage_for_tables(JOIN *join, ulonglong options, // tab-1); prev_tab); tab->use_join_cache= test(tab->used_join_cache_level); - DBUG_ASSERT(!join->return_tab); + /* + psergey-merge: todo: raise the question that this is really stupid that + we can first allocate a join buffer, then decide not to use it and free + it. + */ /* if (join->return_tab) i= join->return_tab-join->join_tab-1; // always >= 0 */ + if (join->return_tab) + { + tab= join->return_tab; + goto restart; + } break; default: tab->used_join_cache_level= 0;