diff --git a/mysql-test/suite/rpl/r/rpl_mdev382.result b/mysql-test/suite/rpl/r/rpl_mdev382.result index b564dd8401e..bbc57006d0d 100644 --- a/mysql-test/suite/rpl/r/rpl_mdev382.result +++ b/mysql-test/suite/rpl/r/rpl_mdev382.result @@ -321,9 +321,7 @@ a` # The DELETE statement should be correctly quoted show binlog events in 'master-bin.000002' from ; Log_name Pos Event_type Server_id End_log_pos Info -master-bin.000002 # Query # # BEGIN -master-bin.000002 # Query # # use `test`; DELETE FROM `db1``; select 'oops!'`.`t``1` -master-bin.000002 # Query # # COMMIT +master-bin.000002 # Query # # DELETE FROM `db1``; select 'oops!'`.`t``1` include/start_slave.inc # The table should be empty on the slave also. SELECT * FROM `db1``; select 'oops!'`.`t``1`; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 52569f193aa..a1e00b74a47 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -3893,34 +3893,22 @@ static bool open_table_entry_fini(THD *thd, TABLE_SHARE *share, TABLE *entry) { char query_buf[2*FN_REFLEN + 21]; String query(query_buf, sizeof(query_buf), system_charset_info); + query.length(0); - if (query.ptr()) - { - /* this DELETE FROM is needed even with row-based binlogging */ - query.append("DELETE FROM "); - append_identifier(thd, &query, share->db.str, share->db.length); - query.append("."); - append_identifier(thd, &query, share->table_name.str, + query.append("DELETE FROM "); + append_identifier(thd, &query, share->db.str, share->db.length); + query.append("."); + append_identifier(thd, &query, share->table_name.str, share->table_name.length); - int errcode= query_error_code(thd, TRUE); - if (thd->binlog_query(THD::STMT_QUERY_TYPE, - query.ptr(), query.length(), - FALSE, FALSE, FALSE, errcode)) - return TRUE; - } - else - { - /* - As replication is maybe going to be corrupted, we need to warn the - DBA on top of warning the client (which will automatically be done - because of MYF(MY_WME) in my_malloc() above). - */ - sql_print_error("When opening HEAP table, could not allocate memory " - "to write 'DELETE FROM %`s.%`s' to the binary log", - share->db.str, share->table_name.str); - delete entry->triggers; + + /* + we bypass thd->binlog_query() here, + as it does a lot of extra work, that is simply wrong in this case + */ + Query_log_event qinfo(thd, query.ptr(), query.length(), + FALSE, TRUE, TRUE, 0); + if (mysql_bin_log.write(&qinfo)) return TRUE; - } } } return FALSE;