From: Date: February 19 2007 11:12am Subject: bk commit into 5.1 tree (mats:1.2406) BUG#23171 List-Archive: http://lists.mysql.com/commits/20074 X-Bug: 23171 Message-Id: <20070219101231.DEB649779@romeo> Below is the list of changes that have just been committed into a local 5.1 repository of mats. When mats does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet@stripped, 2007-02-19 11:12:22+01:00, mats@romeo.(none) +8 -0 BUG#23171 (Illegal slave restart group position): Fixing code that ignores Intvar and Uservar events. Fixing code that ignores events when the server id of the event is identical to the server id of the server. Fixing problems with mysqlbinlog use of new framework. Introducing relay-log info specific version of replicate_same_server_id. mysql-test/t/rpl_row_mysqlbinlog.test@stripped, 2007-02-19 11:12:17+01:00, mats@romeo.(none) +35 -43 Replacing selects with echo to remove unnecessary server round-trip. sql/log.cc@stripped, 2007-02-19 11:12:17+01:00, mats@romeo.(none) +5 -5 Removing unnecessary printf() warnings. sql/log_event.cc@stripped, 2007-02-19 11:12:18+01:00, mats@romeo.(none) +59 -45 Replacing global variable replicate_same_server_id with field in relay log info structure. Name change EVENT_NOT_SKIPPED -> EVENT_SKIP_NOT. Adding debug messages. Fixing code for ignoring Intvar and Uservar events to mimic old behavior. Removing extreneous argument to slave_print_msg() causing compile warning. sql/log_event.h@stripped, 2007-02-19 11:12:18+01:00, mats@romeo.(none) +72 -37 Name change EVENT_NOT_SKIPPED -> EVENT_SKIP_NOT Name change EVENT_SKIP_SAME_SID -> EVENT_SKIP_IGNORE Adding/fixing Doxygen documentation. Adding debug messages. sql/rpl_rli.cc@stripped, 2007-02-19 11:12:18+01:00, mats@romeo.(none) +2 -1 Initializing st_relay_log_info::replicate_same_server_id from ::replicate_same_server_id. sql/rpl_rli.h@stripped, 2007-02-19 11:12:18+01:00, mats@romeo.(none) +9 -0 Adding new field replicate_same_server_id to st_relay_log_info. sql/slave.cc@stripped, 2007-02-19 11:12:18+01:00, mats@romeo.(none) +2 -13 Changes to use st_relay_log_info::replicate_same_server_id instead of global version. Moving comment about how events are skipped to Log_event::exec_event(). sql/sql_binlog.cc@stripped, 2007-02-19 11:12:18+01:00, mats@romeo.(none) +2 -0 Setting replicate_same_server_id for fake RLI used by BINLOG statement. Setting data lock that is released inside Log_event::exec_event(). # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: mats # Host: romeo.(none) # Root: /home/bk/b23171-mysql-5.1-new-rpl --- 1.254/sql/log.cc 2007-02-19 11:12:31 +01:00 +++ 1.255/sql/log.cc 2007-02-19 11:12:31 +01:00 @@ -147,8 +147,8 @@ */ void truncate(my_off_t pos) { - DBUG_PRINT("info", ("truncating to position %lu", pos)); - DBUG_PRINT("info", ("before_stmt_pos=%lu", pos)); + DBUG_PRINT("info", ("truncating to position %lu", (ulong) pos)); + DBUG_PRINT("info", ("before_stmt_pos=%lu", (ulong) pos)); delete pending(); set_pending(0); reinit_io_cache(&trans_log, WRITE_CACHE, pos, 0, 0); @@ -3488,10 +3488,10 @@ { DBUG_ENTER("binlog_flush_transaction_cache"); binlog_trx_data *trx_data= (binlog_trx_data*) ha_data[binlog_hton->slot]; - DBUG_PRINT("enter", ("trx_data=0x%lu", trx_data)); + DBUG_PRINT("enter", ("trx_data=0x%lu", (ulong) trx_data)); if (trx_data) - DBUG_PRINT("enter", ("trx_data->before_stmt_pos=%u", - trx_data->before_stmt_pos)); + DBUG_PRINT("enter", ("trx_data->before_stmt_pos=%lu", + (ulong) trx_data->before_stmt_pos)); /* Write the transaction cache to the binary log. We don't flush and --- 1.263/sql/log_event.cc 2007-02-19 11:12:31 +01:00 +++ 1.264/sql/log_event.cc 2007-02-19 11:12:31 +01:00 @@ -612,12 +612,17 @@ Log_event::enum_skip_reason Log_event::shall_skip(RELAY_LOG_INFO *rli) { - if (this->server_id == ::server_id && !replicate_same_server_id) - return EVENT_SKIP_SAME_SID; + DBUG_PRINT("info", ("ev->server_id=%u, ::server_id=%u," + " rli->replicate_same_server_id=%d," + " rli->slave_skip_counter=%d", + server_id, ::server_id, rli->replicate_same_server_id, + rli->slave_skip_counter)); + if (server_id == ::server_id && !rli->replicate_same_server_id) + return EVENT_SKIP_IGNORE; else if (rli->slave_skip_counter > 0) return EVENT_SKIP_COUNT; else - return EVENT_NOT_SKIPPED; + return EVENT_SKIP_NOT; } @@ -2629,7 +2634,7 @@ Log_event::enum_skip_reason Format_description_log_event::shall_skip(RELAY_LOG_INFO *rli) { - return Log_event::EVENT_NOT_SKIPPED; + return Log_event::EVENT_SKIP_NOT; } #endif @@ -3139,7 +3144,7 @@ */ int Load_log_event::do_apply_event(NET* net, RELAY_LOG_INFO const *rli, - bool use_rli_only_for_errors) + bool use_rli_only_for_errors) { LEX_STRING new_db; new_db.length= db_len; @@ -3478,6 +3483,7 @@ ident_offset = post_header_len; set_if_smaller(ident_len,FN_REFLEN-1); new_log_ident= my_strndup(buf + ident_offset, (uint) ident_len, MYF(MY_WME)); + DBUG_PRINT("debug", ("new_log_ident: '%s'", new_log_ident)); DBUG_VOID_RETURN; } @@ -3500,11 +3506,17 @@ /** Helper function to detect if the event is inside a group. */ +#if defined(HAVE_REPLICATION) && !defined(MYSQL_CLIENT) static bool is_in_group(THD *const thd, RELAY_LOG_INFO *const rli) { + DBUG_PRINT("debug", ("thd->options & OPTION_BEGIN %s 0", + (thd->options & OPTION_BEGIN) == 0 ? "==" : "!=")); + DBUG_PRINT("debug", ("rli->last_event_start_time=%lu", + rli->last_event_start_time)); return (thd->options & OPTION_BEGIN) != 0 || (rli->last_event_start_time > 0); } +#endif /* @@ -3532,7 +3544,8 @@ char buf[32]; #endif - DBUG_PRINT("info", ("server_id=%lu; ::server_id=%lu", this->server_id, ::server_id)); + DBUG_PRINT("info", ("server_id=%lu; ::server_id=%lu", + (ulong) this->server_id, (ulong) ::server_id)); DBUG_PRINT("info", ("new_log_ident: %s", this->new_log_ident)); DBUG_PRINT("info", ("pos: %s", llstr(this->pos, buf))); @@ -3552,10 +3565,15 @@ In that case, we don't want to touch the coordinates which correspond to the beginning of the transaction. Starting from 5.0.0, there also are some rotates from the slave itself, in the - relay log. + relay log, which shall not change the group positions. */ - if (!is_in_group(thd, rli)) + if ((server_id != ::server_id || rli->replicate_same_server_id) && + !is_in_group(thd, rli)) { + DBUG_PRINT("info", ("old group_master_log_name: '%s' " + "old group_master_log_pos: %lu", + rli->group_master_log_name, + (ulong) rli->group_master_log_pos)); memcpy(rli->group_master_log_name, new_log_ident, ident_len+1); rli->notify_group_master_log_name_update(); rli->group_master_log_pos= pos; @@ -3588,16 +3606,15 @@ Log_event::enum_skip_reason Rotate_log_event::shall_skip(RELAY_LOG_INFO *rli) { - enum_skip_reason reason= Log_event::shall_skip(rli); switch (reason) { - case Log_event::EVENT_NOT_SKIPPED: + case Log_event::EVENT_SKIP_NOT: case Log_event::EVENT_SKIP_COUNT: - return Log_event::EVENT_NOT_SKIPPED; + return Log_event::EVENT_SKIP_NOT; - case Log_event::EVENT_SKIP_SAME_SID: - return Log_event::EVENT_SKIP_SAME_SID; + case Log_event::EVENT_SKIP_IGNORE: + return Log_event::EVENT_SKIP_IGNORE; } DBUG_ASSERT(0); } @@ -3737,16 +3754,15 @@ Intvar_log_event::shall_skip(RELAY_LOG_INFO *rli) { /* - It is a common error to set the slave skip counter to 1 instead - of 2 when recovering from an insert which used a auto increment, - rand, or user var. Therefore, if the slave skip counter is 1, - we just say that this event should be skipped because of the - slave skip count, but we do not change the value of the slave - skip counter since it will be decreased by the following insert - event. + It is a common error to set the slave skip counter to 1 instead of + 2 when recovering from an insert which used a auto increment, + rand, or user var. Therefore, if the slave skip counter is 1, we + just say that this event should be skipped by ignoring it, meaning + that we do not change the value of the slave skip counter since it + will be decreased by the following insert event. */ if (rli->slave_skip_counter == 1) - return Log_event::EVENT_SKIP_COUNT; + return Log_event::EVENT_SKIP_IGNORE; else return Log_event::shall_skip(rli); } @@ -3831,16 +3847,15 @@ Rand_log_event::shall_skip(RELAY_LOG_INFO *rli) { /* - It is a common error to set the slave skip counter to 1 instead - of 2 when recovering from an insert which used a auto increment, - rand, or user var. Therefore, if the slave skip counter is 1, - we just say that this event should be skipped because of the - slave skip count, but we do not change the value of the slave - skip counter since it will be decreased by the following insert - event. + It is a common error to set the slave skip counter to 1 instead of + 2 when recovering from an insert which used a auto increment, + rand, or user var. Therefore, if the slave skip counter is 1, we + just say that this event should be skipped by ignoring it, meaning + that we do not change the value of the slave skip counter since it + will be decreased by the following insert event. */ if (rli->slave_skip_counter == 1) - return Log_event::EVENT_SKIP_COUNT; + return Log_event::EVENT_SKIP_IGNORE; else return Log_event::shall_skip(rli); } @@ -4271,21 +4286,20 @@ Log_event::enum_skip_reason User_var_log_event::shall_skip(RELAY_LOG_INFO *rli) - { - /* - It is a common error to set the slave skip counter to 1 instead - of 2 when recovering from an insert which used a auto increment, - rand, or user var. Therefore, if the slave skip counter is 1, - we just say that this event should be skipped because of the - slave skip count, but we do not change the value of the slave - skip counter since it will be decreased by the following insert - event. - */ - if (rli->slave_skip_counter == 1) - return Log_event::EVENT_SKIP_COUNT; - else - return Log_event::shall_skip(rli); - } +{ + /* + It is a common error to set the slave skip counter to 1 instead + of 2 when recovering from an insert which used a auto increment, + rand, or user var. Therefore, if the slave skip counter is 1, we + just say that this event should be skipped by ignoring it, meaning + that we do not change the value of the slave skip counter since it + will be decreased by the following insert event. + */ + if (rli->slave_skip_counter == 1) + return Log_event::EVENT_SKIP_IGNORE; + else + return Log_event::shall_skip(rli); +} #endif /* !MYSQL_CLIENT */ @@ -5997,7 +6011,7 @@ default: slave_print_msg(ERROR_LEVEL, rli, thd->net.last_errno, "Error in %s event: row application failed", - get_type_str(), error); + get_type_str()); thd->query_error= 1; break; } --- 1.139/sql/log_event.h 2007-02-19 11:12:31 +01:00 +++ 1.140/sql/log_event.h 2007-02-19 11:12:31 +01:00 @@ -587,9 +587,28 @@ class Log_event { public: + /** + Enumeration of what kinds of skipping (and non-skipping) that can + occur when the slave executes an event. + + @see shall_skip + */ enum enum_skip_reason { - EVENT_NOT_SKIPPED, - EVENT_SKIP_SAME_SID, + /** + Don't skip event. + */ + EVENT_SKIP_NOT, + + /** + Skip event by ignoring it. + + This means that the slave skip counter will not be changed. + */ + EVENT_SKIP_IGNORE, + + /** + Skip event and decrease skip counter. + */ EVENT_SKIP_COUNT }; @@ -682,9 +701,25 @@ The event will be executed unless it is supposed to be skipped. - @pre The @c rli->data_lock shall be locked. + Queries originating from this server must be skipped. Low-level + events (Format_description_log_event, Rotate_log_event, + Stop_log_event) from this server must also be skipped. But for + those we don't want to modify group_master_log_pos, + because these events did not exist on the master. + Format_description_log_event is not completely skipped. + + Skip queries specified by the user in + slave_skip_counter. We can't however skip events + that has something to do with the log files themselves. + + Filtering on own server id is extremely important, to ignore + execution of events created by the creation/rotation of the relay + log (remember that now the relay log starts with its Format_desc, + has a Rotate etc). + + @pre The rli->data_lock shall be locked. - @post The @c rli->data_lock will be unlocked. + @post The rli->data_lock will be unlocked. @note It is assumed that the @c rli->data_lock is locked before calling this routine. This is because the lock has to be released @@ -710,15 +745,30 @@ { DBUG_ENTER("exec_event"); safe_mutex_assert_owner(&rli->data_lock); +#ifndef DBUG_OFF + static const char *const explain[] = { + "event was not skipped", // EVENT_SKIP_NOT, + "event originated from this server", // EVENT_SKIP_IGNORE, + "event skip counter was non-zero" // EVENT_SKIP_COUNT + }; +#endif int reason= shall_skip(rli); int error= 0; char buf[22]; if (reason == EVENT_SKIP_COUNT) --rli->slave_skip_counter; pthread_mutex_unlock(&rli->data_lock); - if (reason == EVENT_NOT_SKIPPED) + if (reason == EVENT_SKIP_NOT) + { if ((error= do_apply_event(rli))) + { + DBUG_PRINT("info", ("apply_event error = %d", error)); DBUG_RETURN(error); + } + } + else + DBUG_PRINT("info", ("%s was skipped because %s", + get_type_str(), explain[reason])); DBUG_PRINT("info", ("apply_event error = %d", error)); error= do_update_pos(rli); DBUG_PRINT("info", ("update_pos error = %d", error)); @@ -849,25 +899,29 @@ virtual int do_update_pos(RELAY_LOG_INFO *rli); /** - Skip this event if it should be skipped and update skipping - information accordingly. + Decide if this event shall be skipped or not and the reason for + skipping it. - The default implementation will skip the event if either: + The default implementation decide that the event shall be skipped + if either: - the server id of the event is the same as the server id of the - server and replicate_same_server_id is true, or + server and rli->replicate_same_server_id is true, + or - if rli->slave_skip_counter is greater than zero. @see do_apply_event @see do_update_pos - @retval ERR_EVENT_NOT_SKIPPED + @retval ERR_EVENT_SKIP_NOT The event shall not be skipped and should be applied. - @retval ERR_EVENT_SKIP_SAME_SID - The event shall be skipped because the server id of the event is - identical to the server id of the server. + @retval ERR_EVENT_SKIP_IGNORE + The event shall be skipped by just ignoring it, i.e., the slave + skip counter shall not be changed. This happends if, for example, + the originating server id of the event is the same as the server + id of the slave. @retval ERR_EVENT_SKIP_COUNT The event shall be skipped because the slave skip counter was @@ -875,25 +929,6 @@ */ virtual enum_skip_reason shall_skip(RELAY_LOG_INFO *rli); - /** - Decide if it is allowed to stop after execution of this event. - - In some situations, it is not possible to stop right after an - event since it can be in the middle of an execution group. This - member function is used to check if this event is in such a - situation that stopping here might lead to failures when - restarting. - - @param rli Pointer to relay log information - - @retval true We can safely stop after this event - @retval false We cannot stop safely after this event - */ - virtual bool can_stop_safely(RELAY_LOG_INFO const *rli) const { - /* !!! Not Yet Implemted !!! */ - return true; - } - #endif }; @@ -1214,7 +1249,7 @@ } int do_apply_event(NET *net, RELAY_LOG_INFO const *rli, - bool use_rli_only_for_errors); + bool use_rli_only_for_errors); #endif }; @@ -1303,9 +1338,9 @@ decrease the slave skip counter. */ if (this->server_id == ::server_id) - return Log_event::EVENT_SKIP_SAME_SID; + return Log_event::EVENT_SKIP_IGNORE; else - return Log_event::EVENT_NOT_SKIPPED; + return Log_event::EVENT_SKIP_NOT; } #endif }; @@ -1574,9 +1609,9 @@ decrease the slave skip counter. */ if (this->server_id == ::server_id) - return Log_event::EVENT_SKIP_SAME_SID; + return Log_event::EVENT_SKIP_IGNORE; else - return Log_event::EVENT_NOT_SKIPPED; + return Log_event::EVENT_SKIP_NOT; } #endif }; --- 1.296/sql/slave.cc 2007-02-19 11:12:31 +01:00 +++ 1.297/sql/slave.cc 2007-02-19 11:12:31 +01:00 @@ -811,7 +811,7 @@ { if ((master_row= mysql_fetch_row(master_res)) && (::server_id == strtoul(master_row[1], 0, 10)) && - !replicate_same_server_id) + !mi->rli.replicate_same_server_id) errmsg= "The slave I/O thread stops because master and slave have equal \ MySQL server ids; these ids must be different for replication to work (or \ the --replicate-same-server-id option must be used on slave but this does \ @@ -1732,17 +1732,6 @@ int exec_res; /* - Queries originating from this server must be skipped. - Low-level events (Format_desc, Rotate, Stop) from this server - must also be skipped. But for those we don't want to modify - group_master_log_pos, because these events did not exist on the master. - Format_desc is not completely skipped. - Skip queries specified by the user in slave_skip_counter. - We can't however skip events that has something to do with the - log files themselves. - Filtering on own server id is extremely important, to ignore execution of - events created by the creation/rotation of the relay log (remember that - now the relay log starts with its Format_desc, has a Rotate etc). */ DBUG_PRINT("info",("type_code=%d (%s), server_id=%d", @@ -2921,7 +2910,7 @@ pthread_mutex_lock(log_lock); if ((uint4korr(buf + SERVER_ID_OFFSET) == ::server_id) && - !replicate_same_server_id) + !mi->rli.replicate_same_server_id) { /* Do not write it to the relay log. --- 1.2/mysql-test/t/rpl_row_mysqlbinlog.test 2007-02-19 11:12:31 +01:00 +++ 1.3/mysql-test/t/rpl_row_mysqlbinlog.test 2007-02-19 11:12:31 +01:00 @@ -14,9 +14,8 @@ # Setup Section # we need this for getting fixed timestamps inside of this test ---disable_query_log -select "---Setup Section --" as ""; ---enable_query_log +--echo +--echo ---Setup Section -- set timestamp=1000000000; @@ -57,9 +56,8 @@ --enable_query_log ---disable_query_log -select "---Test1 check table load --" as ""; ---enable_query_log +--echo +--echo ---Test1 check table load -- # Lets Check the tables on the Master SELECT COUNT(*) from t1; @@ -88,22 +86,20 @@ flush logs; # delimiters are for easier debugging in future ---disable_query_log -select "--- Test 1 Dump binlog to file --" as ""; ---enable_query_log +--echo +--echo --- Test 1 Dump binlog to file -- # # Prepare local temporary file to recreate what we have currently. ---exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/master.sql +--exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/log/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/rpl_row_mysqlbinlog_master.sql ---exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/log/master-bin.000002 >> $MYSQLTEST_VARDIR/tmp/master.sql +--exec $MYSQL_BINLOG $MYSQLTEST_VARDIR/log/master-bin.000002 >> $MYSQLTEST_VARDIR/tmp/rpl_row_mysqlbinlog_master.sql # Now that we have our file, lets get rid of the current database. # Cleanup the master and the slave and try to recreate. ---disable_query_log -select "--- Test 1 delete tables, clean master and slave --" as ""; ---enable_query_log +--echo +--echo --- Test 1 delete tables, clean master and slave -- DROP TABLE t1; DROP TABLE t2; @@ -127,15 +123,13 @@ connection master; # We should be clean at this point, now we will run in the file from above. ---disable_query_log -select "--- Test 1 Load from Dump binlog file --" as ""; ---enable_query_log +--echo +--echo --- Test 1 Load from Dump binlog file -- ---exec $MYSQL -e "source $MYSQLTEST_VARDIR/tmp/master.sql" +--exec $MYSQL -e "source $MYSQLTEST_VARDIR/tmp/rpl_row_mysqlbinlog_master.sql" ---disable_query_log -select "--- Test 1 Check Load Results --" as ""; ---enable_query_log +--echo +--echo --- Test 1 Check Load Results -- # Lets Check the tables on the Master SELECT COUNT(*) from t1; @@ -158,23 +152,22 @@ # We should be gold by the time, so I will get rid of our file. ---exec rm $MYSQLTEST_VARDIR/tmp/master.sql +#--exec rm $MYSQLTEST_VARDIR/tmp/rpl_row_mysqlbinlog_master.sql # this test for position option # By setting this position to 412, we should only get the create of t3 ---disable_query_log -select "--- Test 2 position test --" as ""; ---enable_query_log +--echo +--echo --- Test 2 position test -- + --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --position=412 $MYSQLTEST_VARDIR/log/master-bin.000001 # These are tests for remote binlog. # They should return the same as previous test. ---disable_query_log -select "--- Test 3 First Remote test --" as ""; ---enable_query_log +--echo +--echo --- Test 3 First Remote test -- # This is broken now --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR @@ -245,30 +238,30 @@ ################### End Bug 17654 ###################### # LOAD DATA ---disable_query_log -select "--- Test 5 LOAD DATA --" as ""; ---enable_query_log +--echo +--echo --- Test 5 LOAD DATA -- + --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR --exec $MYSQL_BINLOG --short-form --local-load=$MYSQLTEST_VARDIR/tmp/ --read-from-remote-server --user=root --host=127.0.0.1 --port=$MASTER_MYPORT master-bin.000002 # Bug#7853 (mysqlbinlog does not accept input from stdin) ---disable_query_log -select "--- Test 6 reading stdin --" as ""; ---enable_query_log +--echo +--echo --- Test 6 reading stdin -- + --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR --exec $MYSQL_BINLOG --short-form - < $MYSQLTEST_VARDIR/log/master-bin.000001 ---disable_query_log -select "--- Test 7 reading stdin w/position --" as ""; ---enable_query_log +--echo +--echo --- Test 7 reading stdin w/position -- + --replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR --exec $MYSQL_BINLOG --short-form --position=412 - < $MYSQLTEST_VARDIR/log/master-bin.000001 # Bug#16217 (mysql client did not know how not switch its internal charset) ---disable_query_log -select "--- Test 8 switch internal charset --" as ""; ---enable_query_log +--echo +--echo --- Test 8 switch internal charset -- + sync_slave_with_master; #we expect STOP SLAVE to produce a warning as the slave is stopped @@ -308,9 +301,8 @@ select HEX(f) from t05; select HEX(f) from t5; ---disable_query_log -select "--- Test cleanup --" as ""; ---enable_query_log +--echo +--echo --- Test cleanup -- # clean up connection master; DROP TABLE IF EXISTS t1, t2, t3, t04, t05, t4, t5; --- 1.5/sql/rpl_rli.cc 2007-02-19 11:12:31 +01:00 +++ 1.6/sql/rpl_rli.cc 2007-02-19 11:12:31 +01:00 @@ -28,7 +28,8 @@ st_relay_log_info::st_relay_log_info() - :no_storage(FALSE), info_fd(-1), cur_log_fd(-1), save_temporary_tables(0), + :no_storage(FALSE), replicate_same_server_id(::replicate_same_server_id), + info_fd(-1), cur_log_fd(-1), save_temporary_tables(0), cur_log_old_open_count(0), group_master_log_pos(0), log_space_total(0), ignore_log_space_limit(0), last_master_timestamp(0), slave_skip_counter(0), abort_pos_wait(0), slave_run_id(0), sql_thd(0), last_slave_errno(0), --- 1.10/sql/rpl_rli.h 2007-02-19 11:12:31 +01:00 +++ 1.11/sql/rpl_rli.h 2007-02-19 11:12:31 +01:00 @@ -56,6 +56,15 @@ */ bool no_storage; + /* + If true, events with the same server id should be replicated. This + field is set on creation of a relay log info structure by copying + the value of ::replicate_same_server_id and can be overridden if + necessary. For example of when this is done, check sql_binlog.cc, + where the BINLOG statement can be used to execute "raw" events. + */ + bool replicate_same_server_id; + /*** The following variables can only be read when protect by data lock ****/ /* --- 1.8/sql/sql_binlog.cc 2007-02-19 11:12:31 +01:00 +++ 1.9/sql/sql_binlog.cc 2007-02-19 11:12:31 +01:00 @@ -71,6 +71,7 @@ thd->rli_fake->sql_thd= thd; thd->rli_fake->no_storage= TRUE; + thd->rli_fake->replicate_same_server_id= TRUE; for (char const *strptr= thd->lex->comment.str ; strptr < thd->lex->comment.str + thd->lex->comment.length ; ) @@ -163,6 +164,7 @@ (ulong) uint4korr(bufptr+EVENT_LEN_OFFSET))); #endif ev->thd= thd; + pthread_mutex_lock(&thd->rli_fake->data_lock); if (int err= ev->exec_event(thd->rli_fake)) { DBUG_PRINT("error", ("exec_event() returned: %d", err));