#At lp:maria based on revid:psergey@askmonty.org-20090614100110-u7l54gk0b6zbtj50 2713 Sergey Petrunia 2009-06-14 MWL#17: Table elimination - Fix the previous cset: take into account that select_lex may be printed when 1. There is no select_lex->join at all (in that case, assume that no tables were eliminated) 2. select_lex->join exists but there was no JOIN::optimize() call yet. handle this by initializing join->eliminated really early. modified: sql/sql_select.cc sql/sql_select.h per-file messages: sql/sql_select.cc MWL#17: Table elimination - Fix the previous cset: take into account that select_lex may be printed when 1. There is no select_lex->join at all (in that case, assume that no tables were eliminated) 2. select_lex->join exists but there was no JOIN::optimize() call yet. handle this by initializing join->eliminated really early. sql/sql_select.h MWL#17: Table elimination - Fix the previous cset: take into account that select_lex may be printed when 1. There is no select_lex->join at all (in that case, assume that no tables were eliminated) 2. select_lex->join exists but there was no JOIN::optimize() call yet. handle this by initializing join->eliminated really early. === modified file 'sql/sql_select.cc' --- a/sql/sql_select.cc 2009-06-14 10:01:10 +0000 +++ b/sql/sql_select.cc 2009-06-14 12:35:04 +0000 @@ -2731,7 +2731,7 @@ static void eliminate_tables(JOIN *join, table_map used_tables; DBUG_ENTER("eliminate_tables"); - join->eliminated_tables= 0; + DBUG_ASSERT(join->eliminated_tables == 0); /* MWL#17 is only about outer join elimination, so: */ if (!join->outer_join) @@ -16888,7 +16888,7 @@ bool mysql_explain_union(THD *thd, SELEC unit->fake_select_lex->options|= SELECT_DESCRIBE; if (!(res= unit->prepare(thd, result, SELECT_NO_UNLOCK | SELECT_DESCRIBE))) res= unit->exec(); - res|= unit->cleanup(); + //psergey-move: res|= unit->cleanup(); } else { @@ -17164,7 +17164,7 @@ void st_select_lex::print(THD *thd, Stri { str->append(STRING_WITH_LEN(" from ")); /* go through join tree */ - print_join(thd, join->eliminated_tables, str, &top_join_list, query_type); + print_join(thd, join? join->eliminated_tables: 0, str, &top_join_list, query_type); } else if (where) { === modified file 'sql/sql_select.h' --- a/sql/sql_select.h 2009-06-14 10:01:10 +0000 +++ b/sql/sql_select.h 2009-06-14 12:35:04 +0000 @@ -427,6 +427,7 @@ public: table= 0; tables= 0; const_tables= 0; + eliminated_tables= 0; join_list= 0; sort_and_group= 0; first_record= 0;