diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index ad7ccaf8f38..1bb1fd9d39a 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2061,6 +2061,16 @@ mysql_execute_command(void) { if (check_table_access(thd,DROP_ACL,tables)) goto error; /* purecov: inspected */ + /* + If this is a slave thread, we may sometimes execute some + DROP / * 40005 TEMPORARY * / TABLE + that come from parts of binlogs (likely if we use RESET SLAVE or CHANGE + MASTER TO), while the temporary table has already been dropped. + To not generate such irrelevant "table does not exist errors", we silently + add IF EXISTS if TEMPORARY was used. + */ + if (thd->slave_thread && lex->drop_temporary) + lex->drop_if_exists= 1; if (end_active_trans(thd)) res= -1; else