diff options
Diffstat (limited to 'sql/log.cc')
-rw-r--r-- | sql/log.cc | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/sql/log.cc b/sql/log.cc index d2e0e4f5c80..af1c4b79464 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1275,6 +1275,25 @@ int LOGGER::set_handlers(uint error_log_printer, return 0; } +/** + This function checks if a transactional talbe was updated by the + current statement. + + @param thd The client thread that executed the current statement. + @return + @c true if a transactional table was updated, @false otherwise. +*/ +static bool stmt_has_updated_trans_table(THD *thd) +{ + Ha_trx_info *ha_info; + + for (ha_info= thd->transaction.stmt.ha_list; ha_info; ha_info= ha_info->next()) + { + if (ha_info->is_trx_read_write() && ha_info->ht() != binlog_hton) + return (TRUE); + } + return (FALSE); +} /* Save position of binary log transaction cache. @@ -4104,7 +4123,8 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info) (binlog_trx_data*) thd_get_ha_data(thd, binlog_hton); IO_CACHE *trans_log= &trx_data->trans_log; my_off_t trans_log_pos= my_b_tell(trans_log); - if (event_info->get_cache_stmt() || trans_log_pos != 0) + if (event_info->get_cache_stmt() || trans_log_pos != 0 || + stmt_has_updated_trans_table(thd)) { DBUG_PRINT("info", ("Using trans_log: cache: %d, trans_log_pos: %lu", event_info->get_cache_stmt(), @@ -4856,7 +4876,8 @@ bool flush_error_log() my_rename(log_error_file,err_renamed,MYF(0)); if (freopen(log_error_file,"a+",stdout)) { - freopen(log_error_file,"a+",stderr); + FILE *reopen; + reopen= freopen(log_error_file,"a+",stderr); setbuf(stderr, NULL); } else |