summaryrefslogtreecommitdiff
path: root/sql/log.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/log.cc')
-rw-r--r--sql/log.cc33
1 files changed, 28 insertions, 5 deletions
diff --git a/sql/log.cc b/sql/log.cc
index e7a142230b1..09e83392dac 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -31,6 +31,7 @@
#include <m_ctype.h> // For test_if_number
MYSQL_LOG mysql_log,mysql_update_log,mysql_slow_log,mysql_bin_log;
+ulong sync_binlog_counter= 0;
static bool test_if_number(const char *str,
long *res, bool allow_wildcards);
@@ -1164,6 +1165,13 @@ bool MYSQL_LOG::write(THD *thd,enum enum_server_command command,
}
+inline bool sync_binlog(IO_CACHE *cache)
+{
+ return (sync_binlog_period &&
+ (sync_binlog_period == ++sync_binlog_counter) &&
+ (sync_binlog_counter= 0, my_sync(cache->file, MYF(MY_WME))));
+}
+
/*
Write an event to the binary log
*/
@@ -1261,10 +1269,24 @@ COLLATION_CONNECTION=%lu,COLLATION_DATABASE=%lu,COLLATION_SERVER=%lu",
if (e.write(file))
goto err;
}
+ /*
+ We use the same ONE_SHOT trick for making replication of time zones
+ working in 4.1. Again in 5.0 we have better means for doing this.
+ */
+ if (thd->time_zone_used &&
+ thd->variables.time_zone != global_system_variables.time_zone)
+ {
+ char buf[MAX_TIME_ZONE_NAME_LENGTH + 26];
+ char *buf_end= strxmov(buf, "SET ONE_SHOT TIME_ZONE='",
+ thd->variables.time_zone->get_name()->ptr(),
+ "'", NullS);
+ Query_log_event e(thd, buf, buf_end - buf, 0);
+ e.set_log_pos(this);
+ if (e.write(file))
+ goto err;
+ }
#endif
- /* Add logging of timezones here */
-
if (thd->last_insert_id_used)
{
Intvar_log_event e(thd,(uchar) LAST_INSERT_ID_EVENT,
@@ -1369,9 +1391,9 @@ COLLATION_CONNECTION=%lu,COLLATION_DATABASE=%lu,COLLATION_SERVER=%lu",
if (file == &log_file) // we are writing to the real log (disk)
{
- if (flush_io_cache(file))
+ if (flush_io_cache(file) || sync_binlog(file))
goto err;
-
+
if (opt_using_transactions && !my_b_tell(&thd->transaction.trans_log))
{
/*
@@ -1529,7 +1551,8 @@ bool MYSQL_LOG::write(THD *thd, IO_CACHE *cache, bool commit_or_rollback)
commit_or_rollback ? 6 : 8,
TRUE);
qinfo.set_log_pos(this);
- if (qinfo.write(&log_file) || flush_io_cache(&log_file))
+ if (qinfo.write(&log_file) || flush_io_cache(&log_file) ||
+ sync_binlog(&log_file))
goto err;
}
if (cache->error) // Error on read