Commit b1e25edc authored by Sergey Petrunia's avatar Sergey Petrunia

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. 

parent 402e58cf
...@@ -2731,7 +2731,7 @@ static void eliminate_tables(JOIN *join, uint *const_tbl_count, table_map *const ...@@ -2731,7 +2731,7 @@ static void eliminate_tables(JOIN *join, uint *const_tbl_count, table_map *const
table_map used_tables; table_map used_tables;
DBUG_ENTER("eliminate_tables"); DBUG_ENTER("eliminate_tables");
join->eliminated_tables= 0; DBUG_ASSERT(join->eliminated_tables == 0);
/* MWL#17 is only about outer join elimination, so: */ /* MWL#17 is only about outer join elimination, so: */
if (!join->outer_join) if (!join->outer_join)
...@@ -16888,7 +16888,7 @@ bool mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit, select_result *result) ...@@ -16888,7 +16888,7 @@ bool mysql_explain_union(THD *thd, SELECT_LEX_UNIT *unit, select_result *result)
unit->fake_select_lex->options|= SELECT_DESCRIBE; unit->fake_select_lex->options|= SELECT_DESCRIBE;
if (!(res= unit->prepare(thd, result, SELECT_NO_UNLOCK | SELECT_DESCRIBE))) if (!(res= unit->prepare(thd, result, SELECT_NO_UNLOCK | SELECT_DESCRIBE)))
res= unit->exec(); res= unit->exec();
res|= unit->cleanup(); //psergey-move: res|= unit->cleanup();
} }
else else
{ {
...@@ -17164,7 +17164,7 @@ void st_select_lex::print(THD *thd, String *str, enum_query_type query_type) ...@@ -17164,7 +17164,7 @@ void st_select_lex::print(THD *thd, String *str, enum_query_type query_type)
{ {
str->append(STRING_WITH_LEN(" from ")); str->append(STRING_WITH_LEN(" from "));
/* go through join tree */ /* 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) else if (where)
{ {
......
...@@ -427,6 +427,7 @@ public: ...@@ -427,6 +427,7 @@ public:
table= 0; table= 0;
tables= 0; tables= 0;
const_tables= 0; const_tables= 0;
eliminated_tables= 0;
join_list= 0; join_list= 0;
sort_and_group= 0; sort_and_group= 0;
first_record= 0; first_record= 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment