From b3f18c88664bfb774c84d5a427161f6bfffda1a8 Mon Sep 17 00:00:00 2001 From: Sergey Petrunya Date: Thu, 13 Aug 2009 13:24:02 +0400 Subject: [PATCH] MWL#17: Table elimination - Post-postreview changes fix: Do set NESTED_JOIN::n_tables to number of tables left after elimination. --- sql/sql_select.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 338010aee1b..72136e751bf 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -114,7 +114,7 @@ static COND *simplify_joins(JOIN *join, List *join_list, COND *conds, bool top); static bool check_interleaving_with_nj(JOIN_TAB *next); static void restore_prev_nj_state(JOIN_TAB *last); -static void reset_nj_counters(List *join_list); +static void reset_nj_counters(JOIN *join, List *join_list); static uint build_bitmap_for_nested_joins(List *join_list, uint first_unused); @@ -1011,7 +1011,7 @@ JOIN::optimize() DBUG_RETURN(1); } - reset_nj_counters(join_list); + reset_nj_counters(this, join_list); make_outerjoin_info(this); /* @@ -4625,7 +4625,7 @@ choose_plan(JOIN *join, table_map join_tables) DBUG_ENTER("choose_plan"); join->cur_embedding_map= 0; - reset_nj_counters(join->join_list); + reset_nj_counters(join, join->join_list); /* if (SELECT_STRAIGHT_JOIN option is set) reorder tables so dependent tables come after tables they depend @@ -8791,7 +8791,7 @@ static uint build_bitmap_for_nested_joins(List *join_list, tables which will be ignored. */ -static void reset_nj_counters(List *join_list) +static void reset_nj_counters(JOIN *join, List *join_list) { List_iterator li(*join_list); TABLE_LIST *table; @@ -8802,7 +8802,9 @@ static void reset_nj_counters(List *join_list) if ((nested_join= table->nested_join)) { nested_join->counter= 0; - reset_nj_counters(&nested_join->join_list); + nested_join->n_tables= my_count_bits(nested_join->used_tables & + ~join->eliminated_tables); + reset_nj_counters(join, &nested_join->join_list); } } DBUG_VOID_RETURN;