From b1e25edc9b632224d699a4ba0dba37e9c485b203 Mon Sep 17 00:00:00 2001 From: Sergey Petrunia Date: Sun, 14 Jun 2009 16:35:04 +0400 Subject: [PATCH] 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.cc | 6 +++--- sql/sql_select.h | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 6041cd6edfb..56fb9ac47ba 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -2731,7 +2731,7 @@ static void eliminate_tables(JOIN *join, uint *const_tbl_count, table_map *const 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, SELECT_LEX_UNIT *unit, select_result *result) 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, String *str, enum_query_type query_type) { 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) { diff --git a/sql/sql_select.h b/sql/sql_select.h index 0ca47e7ce13..f209cee4956 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -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;