diff --git a/sql/sql_select.cc b/sql/sql_select.cc index fdee99b88f4..b323cae468d 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -902,9 +902,10 @@ JOIN::optimize() /* Save this info for the next executions */ if (select_lex->save_leaf_tables(thd)) DBUG_RETURN(1); - eval_select_list_used_tables(); } + eval_select_list_used_tables(); + table_count= select_lex->leaf_tables.elements; if (setup_ftfuncs(select_lex)) /* should be after having->fix_fields */