summaryrefslogtreecommitdiff
path: root/sql/log_event.cc
diff options
context:
space:
mode:
authorunknown <guilhem@mysql.com>2004-04-07 00:57:14 +0200
committerunknown <guilhem@mysql.com>2004-04-07 00:57:14 +0200
commite3f0177b984eab8bcdff6c4c8ddc34e087d1297a (patch)
treedf759bb77be6f092820afe360a076630d14db47d /sql/log_event.cc
parent331ff0d8f5e092b9672f66d135d6209897b25846 (diff)
downloadmariadb-git-e3f0177b984eab8bcdff6c4c8ddc34e087d1297a.tar.gz
This is a fix for a bug in 3.23 -> 4.0 replication: Exec_master_log_pos is always
too big by 6 bytes. So I add code to substract 6 bytes if the master is 3.23. This is not perfect (because it won't work if the slave I/O thread has not noticed yet that the master is 3.23), but as long as the slave I/O thread starts Exec_master_log_pos will be ok. It must be merged to 4.1 but not to 5.0 (or it can be, because of #if MYSQL_VERSION_ID), because 5.0 already works if the master is 3.23 (and in a more natural way: in 5.0 we store the end_log_pos in the binlog and relay log). I had to move functions from slave.h to slave.cc to satisfy gcc. sql/log_event.cc: make the event's length 6 bytes shorter if the master is 3.23 sql/slave.cc: Moving several st_relay_log_info methods out of the declaration of the struct, because gcc complained that 'mi' was not declared. Substracting 6 bytes from the event's length in inc_pos() if the master is 3.23. sql/slave.h: moving several methods out of the declaration of st_relay_log_info. Removing 'inline', let's have the compiler decide.
Diffstat (limited to 'sql/log_event.cc')
-rw-r--r--sql/log_event.cc32
1 files changed, 26 insertions, 6 deletions
diff --git a/sql/log_event.cc b/sql/log_event.cc
index a484123b4c7..cd94ee2804d 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -1805,10 +1805,21 @@ int Query_log_event::exec_event(struct st_relay_log_info* rli)
position to store is of the END of the current log event.
*/
#if MYSQL_VERSION_ID < 40100
- rli->future_master_log_pos= log_pos + get_event_len();
+ /*
+ If the event was converted from a 3.23 format, get_event_len() has grown by
+ 6 bytes (at least for most events, except LOAD DATA INFILE which is already
+ a big problem for 3.23->4.0 replication); 6 bytes is the difference between
+ the header's size in 4.0 (LOG_EVENT_HEADER_LEN) and the header's size in
+ 3.23 (OLD_HEADER_LEN). Note that using mi->old_format will not help if the
+ I/O thread has not started yet.
+ */
+ rli->future_master_log_pos= log_pos + get_event_len() -
+ (rli->mi->old_format ? (LOG_EVENT_HEADER_LEN - OLD_HEADER_LEN) : 0);
#elif MYSQL_VERSION_ID < 50000
- rli->future_group_master_log_pos= log_pos + get_event_len();
+ rli->future_group_master_log_pos= log_pos + get_event_len() -
+ (rli->mi->old_format ? (LOG_EVENT_HEADER_LEN - OLD_HEADER_LEN) : 0);
#else
+ /* In 5.0 we store the end_log_pos in the relay log so no problem */
rli->future_group_master_log_pos= log_pos;
#endif
clear_all_errors(thd, rli);
@@ -1960,9 +1971,11 @@ int Load_log_event::exec_event(NET* net, struct st_relay_log_info* rli,
if (!use_rli_only_for_errors)
{
#if MYSQL_VERSION_ID < 40100
- rli->future_master_log_pos= log_pos + get_event_len();
+ rli->future_master_log_pos= log_pos + get_event_len() -
+ (rli->mi->old_format ? (LOG_EVENT_HEADER_LEN - OLD_HEADER_LEN) : 0);
#elif MYSQL_VERSION_ID < 50000
- rli->future_group_master_log_pos= log_pos + get_event_len();
+ rli->future_group_master_log_pos= log_pos + get_event_len() -
+ (rli->mi->old_format ? (LOG_EVENT_HEADER_LEN - OLD_HEADER_LEN) : 0);
#else
rli->future_group_master_log_pos= log_pos;
#endif
@@ -2133,6 +2146,11 @@ Fatal error running LOAD DATA INFILE on table '%s'. Default database: '%s'",
int Start_log_event::exec_event(struct st_relay_log_info* rli)
{
+ /*
+ If the I/O thread has not started, mi->old_format is BINLOG_FORMAT_CURRENT
+ (that's what the MASTER_INFO constructor does), so the test below is not
+ perfect at all.
+ */
switch (rli->mi->old_format) {
case BINLOG_FORMAT_CURRENT :
/*
@@ -2427,9 +2445,11 @@ int Execute_load_log_event::exec_event(struct st_relay_log_info* rli)
*/
#if MYSQL_VERSION_ID < 40100
- rli->future_master_log_pos= log_pos + get_event_len();
+ rli->future_master_log_pos= log_pos + get_event_len() -
+ (rli->mi->old_format ? (LOG_EVENT_HEADER_LEN - OLD_HEADER_LEN) : 0);
#elif MYSQL_VERSION_ID < 50000
- rli->future_group_master_log_pos= log_pos + get_event_len();
+ rli->future_group_master_log_pos= log_pos + get_event_len() -
+ (rli->mi->old_format ? (LOG_EVENT_HEADER_LEN - OLD_HEADER_LEN) : 0);
#else
rli->future_group_master_log_pos= log_pos;
#endif