diff options
author | unknown <Li-Bing.Song@sun.com> | 2009-11-22 13:10:33 +0800 |
---|---|---|
committer | unknown <Li-Bing.Song@sun.com> | 2009-11-22 13:10:33 +0800 |
commit | a2ed682967bdc29d249d0f607f4eea4d84a81761 (patch) | |
tree | 6701c56560a99667e2201cc764e89c8b8fe8f943 /sql | |
parent | 897d87f63a566481a8ab8a2b27f3973560846ce8 (diff) | |
download | mariadb-git-a2ed682967bdc29d249d0f607f4eea4d84a81761.tar.gz |
Bug #48350 truncate temporary table crashes replication
In RBR, All statements operating on temporary tables should not be binlogged.
Despite this fact, after executing 'TRUNCATE... ' on a temporary table,
the command is still logged, even if in row-based mode. Consequently, this raises
problems in the slave as the table may not exist, resulting in an
execution failure. Ultimately, this causes the slave to report
an error and abort.
After this patch, 'TRUNCATE ...' statement on a temporary table will not be
binlogged in RBR.
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_delete.cc | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 93b19c5b233..6b9a83e695b 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -1090,6 +1090,7 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok) TABLE *table; bool error; uint path_length; + bool is_temporary_table= false; DBUG_ENTER("mysql_truncate"); bzero((char*) &create_info,sizeof(create_info)); @@ -1100,6 +1101,7 @@ bool mysql_truncate(THD *thd, TABLE_LIST *table_list, bool dont_send_ok) /* If it is a temporary table, close and regenerate it */ if (!dont_send_ok && (table= find_temporary_table(thd, table_list))) { + is_temporary_table= true; handlerton *table_type= table->s->db_type(); TABLE_SHARE *share= table->s; if (!ha_check_storage_engine_flag(table_type, HTON_CAN_RECREATE)) @@ -1163,11 +1165,9 @@ end: { if (!error) { - /* - TRUNCATE must always be statement-based binlogged (not row-based) so - we don't test current_stmt_binlog_row_based. - */ - write_bin_log(thd, TRUE, thd->query(), thd->query_length()); + /* In RBR, the statement is not binlogged if the table is temporary. */ + if (!is_temporary_table || !thd->current_stmt_binlog_row_based) + write_bin_log(thd, TRUE, thd->query(), thd->query_length()); my_ok(thd); // This should return record count } VOID(pthread_mutex_lock(&LOCK_open)); |