diff options
Diffstat (limited to 'sql/opt_table_elimination.cc')
-rw-r--r-- | sql/opt_table_elimination.cc | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/sql/opt_table_elimination.cc b/sql/opt_table_elimination.cc index f13ada782f4..3c32e8de3e0 100644 --- a/sql/opt_table_elimination.cc +++ b/sql/opt_table_elimination.cc @@ -1069,16 +1069,26 @@ void eliminate_tables(JOIN *join) if (join->select_lex == &thd->lex->select_lex) { - /* Multi-table UPDATE and DELETE: don't eliminate the tables we modify: */ - used_tables |= thd->table_map_for_update; /* Multi-table UPDATE: don't eliminate tables referred from SET statement */ if (thd->lex->sql_command == SQLCOM_UPDATE_MULTI) { + /* Multi-table UPDATE and DELETE: don't eliminate the tables we modify: */ + used_tables |= thd->table_map_for_update; List_iterator<Item> it2(thd->lex->value_list); while ((item= it2++)) used_tables |= item->used_tables(); } + + if (thd->lex->sql_command == SQLCOM_DELETE_MULTI) + { + TABLE_LIST *tbl; + for (tbl= (TABLE_LIST*)thd->lex->auxiliary_table_list.first; + tbl; tbl= tbl->next_local) + { + used_tables |= tbl->table->map; + } + } } table_map all_tables= join->all_tables_map(); |