Commit a0efc4bd authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-510 assert triggered by ./mtr --ps-protocol rpl_mdev382

The DELETE for emplicitly emptied MEMORY tables should be written directly to binlog.
parent caedd199
...@@ -321,9 +321,7 @@ a` ...@@ -321,9 +321,7 @@ a`
# The DELETE statement should be correctly quoted # The DELETE statement should be correctly quoted
show binlog events in 'master-bin.000002' from <binlog_start>; show binlog events in 'master-bin.000002' from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000002 # Query # # BEGIN master-bin.000002 # Query # # DELETE FROM `db1``; select 'oops!'`.`t``1`
master-bin.000002 # Query # # use `test`; DELETE FROM `db1``; select 'oops!'`.`t``1`
master-bin.000002 # Query # # COMMIT
include/start_slave.inc include/start_slave.inc
# The table should be empty on the slave also. # The table should be empty on the slave also.
SELECT * FROM `db1``; select 'oops!'`.`t``1`; SELECT * FROM `db1``; select 'oops!'`.`t``1`;
......
...@@ -3893,34 +3893,22 @@ static bool open_table_entry_fini(THD *thd, TABLE_SHARE *share, TABLE *entry) ...@@ -3893,34 +3893,22 @@ static bool open_table_entry_fini(THD *thd, TABLE_SHARE *share, TABLE *entry)
{ {
char query_buf[2*FN_REFLEN + 21]; char query_buf[2*FN_REFLEN + 21];
String query(query_buf, sizeof(query_buf), system_charset_info); String query(query_buf, sizeof(query_buf), system_charset_info);
query.length(0); query.length(0);
if (query.ptr()) query.append("DELETE FROM ");
{ append_identifier(thd, &query, share->db.str, share->db.length);
/* this DELETE FROM is needed even with row-based binlogging */ query.append(".");
query.append("DELETE FROM "); append_identifier(thd, &query, share->table_name.str,
append_identifier(thd, &query, share->db.str, share->db.length);
query.append(".");
append_identifier(thd, &query, share->table_name.str,
share->table_name.length); share->table_name.length);
int errcode= query_error_code(thd, TRUE);
if (thd->binlog_query(THD::STMT_QUERY_TYPE, /*
query.ptr(), query.length(), we bypass thd->binlog_query() here,
FALSE, FALSE, FALSE, errcode)) as it does a lot of extra work, that is simply wrong in this case
return TRUE; */
} Query_log_event qinfo(thd, query.ptr(), query.length(),
else FALSE, TRUE, TRUE, 0);
{ if (mysql_bin_log.write(&qinfo))
/*
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;
return TRUE; return TRUE;
}
} }
} }
return FALSE; return FALSE;
......
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