Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mysql-test/suite/rpl/r/rpl_mdev382.result
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ a`
show binlog events in 'master-bin.000002' from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000002 # Gtid 1 # GTID #-#-#
master-bin.000002 # Query 1 # TRUNCATE TABLE `db1``; select 'oops!'`.`t``1`
master-bin.000002 # Query 1 # TRUNCATE TABLE `db1``; select 'oops!'`.`t``1` /* generated by recreated memory table */
connection slave;
include/start_slave.inc
connection master;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ if ($seq_no_before_restart == $seq_no_after_restart)

--let assert_text= Query to truncate the MEMORY table should be the contents of the new event
--let assert_count= 1
--let assert_select= TRUNCATE TABLE
--let assert_select= ^TRUNCATE TABLE .+generated.+memory table
--source include/assert_grep.inc

--echo # Ensuring slave MEMORY table is empty
Expand Down
15 changes: 9 additions & 6 deletions sql/sql_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3284,15 +3284,18 @@ static bool open_table_entry_fini(THD *thd, TABLE_SHARE *share, TABLE *entry)
entry->file->implicit_emptied= 0;
if (mysql_bin_log.is_open())
{
char query_buf[2*FN_REFLEN + 21];
String query(query_buf, sizeof(query_buf), system_charset_info);

query.length(0);
query.append(STRING_WITH_LEN("TRUNCATE TABLE "));
static const char
QUERY_START[]= "TRUNCATE TABLE ",
QUERY_COMMENT[]= " /* generated by recreated memory table */";
StringBuffer<
(sizeof(QUERY_START)-1) + (sizeof(QUERY_COMMENT)-1) +
2 * (FN_REFLEN+3) // identifiers, quotes, and '.' & '\0'
> query(system_charset_info);
query.append(STRING_WITH_LEN(QUERY_START));
append_identifier(thd, &query, &share->db);
query.append('.');
append_identifier(thd, &query, &share->table_name);

query.append(STRING_WITH_LEN(QUERY_COMMENT));
/*
we bypass thd->binlog_query() here,
as it does a lot of extra work, that is simply wrong in this case
Expand Down