diff options
Diffstat (limited to 'sql/log.cc')
| -rw-r--r-- | sql/log.cc | 33 |
1 files changed, 28 insertions, 5 deletions
diff --git a/sql/log.cc b/sql/log.cc index 13ebbd9a3e7..892780d3882 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -873,9 +873,12 @@ bool MYSQL_LOG::write(Log_event* event_info) VOID(pthread_mutex_unlock(&LOCK_log)); return 0; } + error=1; - // no check for auto events flag here - this write method should - // never be called if auto-events are enabled + /* + No check for auto events flag here - this write method should + never be called if auto-events are enabled + */ if (thd && thd->last_insert_id_used) { Intvar_log_event e(thd,(uchar)LAST_INSERT_ID_EVENT,thd->last_insert_id); @@ -913,8 +916,24 @@ bool MYSQL_LOG::write(Log_event* event_info) file == &log_file && flush_io_cache(file)) goto err; error=0; - should_rotate = (file == &log_file && - (uint)my_b_tell(file) >= max_binlog_size); + + /* + Tell for transactional table handlers up to which position in the + binlog file we wrote. The table handler can store this info, and + after crash recovery print for the user the offset of the last + transactions which were recovered. Actually, we must also call + the table handler commit here, protected by the LOCK_log mutex, + because otherwise the transactions may end up in a different order + in the table handler log! + */ + + if (file == &log_file) + { + error = ha_report_binlog_offset_and_commit(thd, log_file_name, + file->pos_in_file); + should_rotate= (my_b_tell(file) >= (my_off_t) max_binlog_size); + } + err: if (error) { @@ -948,7 +967,7 @@ uint MYSQL_LOG::next_file_id() 'cache' needs to be reinitialized after this functions returns. */ -bool MYSQL_LOG::write(IO_CACHE *cache) +bool MYSQL_LOG::write(THD *thd, IO_CACHE *cache) { VOID(pthread_mutex_lock(&LOCK_log)); bool error=1; @@ -984,6 +1003,10 @@ bool MYSQL_LOG::write(IO_CACHE *cache) sql_print_error(ER(ER_ERROR_ON_READ), cache->file_name, errno); goto err; } + error = ha_report_binlog_offset_and_commit(thd, log_file_name, + log_file.pos_in_file); + if (error) + goto err; } error=0; |
