diff --git a/mysql-test/suite/rpl/r/rpl_mdev382.result b/mysql-test/suite/rpl/r/rpl_mdev382.result index b3488da7cc96b..b23cffbd7dd02 100644 --- a/mysql-test/suite/rpl/r/rpl_mdev382.result +++ b/mysql-test/suite/rpl/r/rpl_mdev382.result @@ -355,7 +355,7 @@ a` show binlog events in 'master-bin.000002' from ; 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; diff --git a/mysql-test/suite/rpl/t/rpl_memory_engine_truncate_on_restart.test b/mysql-test/suite/rpl/t/rpl_memory_engine_truncate_on_restart.test index a6e0b39ca8557..90c13c431b1f6 100644 --- a/mysql-test/suite/rpl/t/rpl_memory_engine_truncate_on_restart.test +++ b/mysql-test/suite/rpl/t/rpl_memory_engine_truncate_on_restart.test @@ -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 diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 386f419a5d411..dd2ad530230a5 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -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