Commit ea4f0c38 authored by guilhem@mysql.com's avatar guilhem@mysql.com

Make log_pos be non-zero in the binary log, for BEGIN and COMMIT Query_log_events.

Now log_pos is the real position of the event. For events that are between BEGIN and COMMIT,
log_pos is still the BEGIN's log_pos.
This fixes bug #52 (If only transactions are run on the master then t
parent 8a86f316
...@@ -1211,6 +1211,14 @@ bool MYSQL_LOG::write(THD *thd, IO_CACHE *cache) ...@@ -1211,6 +1211,14 @@ bool MYSQL_LOG::write(THD *thd, IO_CACHE *cache)
*/ */
{ {
Query_log_event qinfo(thd, "BEGIN", 5, TRUE); Query_log_event qinfo(thd, "BEGIN", 5, TRUE);
/*
Now this Query_log_event has artificial log_pos 0. It must be adjusted
to reflect the real position in the log. Not doing it would confuse the
slave: it would prevent this one from knowing where he is in the master's
binlog, which would result in wrong positions being shown to the user,
MASTER_POS_WAIT undue waiting etc.
*/
qinfo.set_log_pos(this);
if (qinfo.write(&log_file)) if (qinfo.write(&log_file))
goto err; goto err;
} }
...@@ -1233,6 +1241,7 @@ bool MYSQL_LOG::write(THD *thd, IO_CACHE *cache) ...@@ -1233,6 +1241,7 @@ bool MYSQL_LOG::write(THD *thd, IO_CACHE *cache)
{ {
Query_log_event qinfo(thd, "COMMIT", 6, TRUE); Query_log_event qinfo(thd, "COMMIT", 6, 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))
goto err; goto err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment