diff --git a/mysql-test/include/show_events.inc b/mysql-test/include/show_events.inc index 7917b6740cf..368cfc9e3a7 100644 --- a/mysql-test/include/show_events.inc +++ b/mysql-test/include/show_events.inc @@ -15,7 +15,19 @@ --let $statement=show BINLOG events if ($is_relay_log) { - --let $statement=show relaylog events + if ($master_name) + { + let _master_name='$master_name'; + } + if (!$master_name) + { + let _master_name=`select @@default_master_connection`; + if ($_master_name) + { + let _master_name='$_master_name'; + } + } + --let $statement=show relaylog $_master_name events } if ($binlog_file) @@ -25,7 +37,7 @@ if ($binlog_file) { if ($is_relay_log) { - --let $_binlog_file= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1) + --let $_binlog_file= query_get_value(SHOW SLAVE $_master_name STATUS, Relay_Log_File, 1) } if (!$is_relay_log) { diff --git a/mysql-test/include/show_relaylog_events.inc b/mysql-test/include/show_relaylog_events.inc index d1bd11f1642..c98e961da76 100644 --- a/mysql-test/include/show_relaylog_events.inc +++ b/mysql-test/include/show_relaylog_events.inc @@ -1,10 +1,11 @@ ############################################################################## # Show relay log events # -# Useage: +# Usage: # let $binlog_file= slave-relay-bin.000002; # let $binlog_start= 106; # let $binlog_limit= 1, 3; +# let $master_name= master1; # source include/show_relaylog_events.inc; # # It shows the first relay log file if $binlog_file is not given. diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index 9bf7c7c9416..5601c9c25e9 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -3800,6 +3800,7 @@ bool mysql_show_binlog_events(THD* thd) int old_max_allowed_packet= thd->variables.max_allowed_packet; Master_info *mi= 0; LOG_INFO linfo; + LEX_MASTER_INFO *lex_mi= &thd->lex->mi; DBUG_ENTER("mysql_show_binlog_events"); @@ -3821,10 +3822,12 @@ bool mysql_show_binlog_events(THD* thd) } else /* showing relay log contents */ { + if (!lex_mi->connection_name.str) + lex_mi->connection_name= thd->variables.default_master_connection; mysql_mutex_lock(&LOCK_active_mi); if (!master_info_index || !(mi= master_info_index-> - get_master_info(&thd->variables.default_master_connection, + get_master_info(&lex_mi->connection_name, Sql_condition::WARN_LEVEL_ERROR))) { mysql_mutex_unlock(&LOCK_active_mi); @@ -3835,7 +3838,6 @@ bool mysql_show_binlog_events(THD* thd) if (binary_log->is_open()) { - LEX_MASTER_INFO *lex_mi= &thd->lex->mi; SELECT_LEX_UNIT *unit= &thd->lex->unit; ha_rows event_count, limit_start, limit_end; my_off_t pos = MY_MAX(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly