mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
BUG#28777, WL#4293: SHOW BINLOG EVENTS does not work on relay log
files NOTE: this is the backport to next-mr. SHOW BINLOG EVENTS does not work with relay log files. If issuing "SHOW BINLOG EVENTS IN 'relay-log.000001'" in a non-empty relay log file (relay-log.000001), mysql reports empty set. This patch addresses this issue by extending the SHOW command with RELAYLOG. Events in relay log files can now be inspected by issuing SHOW RELAYLOG EVENTS [IN 'log_name'] [FROM pos] [LIMIT [offset,] row_count]. mysql-test/extra/rpl_tests/rpl_show_relaylog_events.inc: Shared part of the test case. mysql-test/include/show_binlog_events.inc: Added options $binary_log_file, $binary_log_limit_row, $binary_log_limit_offset so that show_binlog_events can take same parameters as SHOW BINLOG EVENTS does. mysql-test/include/show_relaylog_events.inc: Clone of show_binlog_events for relaylog events. mysql-test/suite/rpl/t/rpl_row_show_relaylog_events.test: Test case for row based replication. mysql-test/suite/rpl/t/rpl_stm_mix_show_relaylog_events.test: Test case for statement and mixed mode replication. sql/lex.h: Added RELAYLOG symbol. sql/mysqld.cc: Added "show_relaylog_events" to status_vars. sql/sp_head.cc: Set SQLCOM_SHOW_RELAYLOG_EVENTS to return flags= sp_head::MULTI_RESULTS; in sp_get_flags_for_command as SQLCOM_SHOW_BINLOG_EVENTS does. sql/sql_lex.h: Added sql_command SQLCOM_SHOW_RELAYLOG_EVENTS to lex enum_sql_command. sql/sql_parse.cc: Added handling of SQLCOM_SHOW_RELAYLOG_EVENTS. sql/sql_repl.cc: mysql_show_binlog_events set to choose the log file to use based on the command issued (SHOW BINLOG|RELAYLOG EVENTS). sql/sql_yacc.yy: Added RELAYLOG to the grammar.
This commit is contained in:
@ -1401,6 +1401,7 @@ bool mysql_show_binlog_events(THD* thd)
|
||||
bool ret = TRUE;
|
||||
IO_CACHE log;
|
||||
File file = -1;
|
||||
MYSQL_BIN_LOG *binary_log= NULL;
|
||||
DBUG_ENTER("mysql_show_binlog_events");
|
||||
|
||||
Log_event::init_show_field_list(&field_list);
|
||||
@ -1411,14 +1412,30 @@ bool mysql_show_binlog_events(THD* thd)
|
||||
Format_description_log_event *description_event= new
|
||||
Format_description_log_event(3); /* MySQL 4.0 by default */
|
||||
|
||||
/*
|
||||
Wait for handlers to insert any pending information
|
||||
into the binlog. For e.g. ndb which updates the binlog asynchronously
|
||||
this is needed so that the uses sees all its own commands in the binlog
|
||||
*/
|
||||
ha_binlog_wait(thd);
|
||||
DBUG_ASSERT(thd->lex->sql_command == SQLCOM_SHOW_BINLOG_EVENTS ||
|
||||
thd->lex->sql_command == SQLCOM_SHOW_RELAYLOG_EVENTS);
|
||||
|
||||
if (mysql_bin_log.is_open())
|
||||
/* select wich binary log to use: binlog or relay */
|
||||
if ( thd->lex->sql_command == SQLCOM_SHOW_BINLOG_EVENTS )
|
||||
{
|
||||
/*
|
||||
Wait for handlers to insert any pending information
|
||||
into the binlog. For e.g. ndb which updates the binlog asynchronously
|
||||
this is needed so that the uses sees all its own commands in the binlog
|
||||
*/
|
||||
ha_binlog_wait(thd);
|
||||
|
||||
binary_log= &mysql_bin_log;
|
||||
}
|
||||
else /* showing relay log contents */
|
||||
{
|
||||
if (!active_mi)
|
||||
DBUG_RETURN(TRUE);
|
||||
|
||||
binary_log= &(active_mi->rli.relay_log);
|
||||
}
|
||||
|
||||
if (binary_log->is_open())
|
||||
{
|
||||
LEX_MASTER_INFO *lex_mi= &thd->lex->mi;
|
||||
SELECT_LEX_UNIT *unit= &thd->lex->unit;
|
||||
@ -1426,7 +1443,7 @@ bool mysql_show_binlog_events(THD* thd)
|
||||
my_off_t pos = max(BIN_LOG_HEADER_SIZE, lex_mi->pos); // user-friendly
|
||||
char search_file_name[FN_REFLEN], *name;
|
||||
const char *log_file_name = lex_mi->log_file_name;
|
||||
pthread_mutex_t *log_lock = mysql_bin_log.get_log_lock();
|
||||
pthread_mutex_t *log_lock = binary_log->get_log_lock();
|
||||
LOG_INFO linfo;
|
||||
Log_event* ev;
|
||||
|
||||
@ -1436,13 +1453,13 @@ bool mysql_show_binlog_events(THD* thd)
|
||||
|
||||
name= search_file_name;
|
||||
if (log_file_name)
|
||||
mysql_bin_log.make_log_name(search_file_name, log_file_name);
|
||||
binary_log->make_log_name(search_file_name, log_file_name);
|
||||
else
|
||||
name=0; // Find first log
|
||||
|
||||
linfo.index_file_offset = 0;
|
||||
|
||||
if (mysql_bin_log.find_log_pos(&linfo, name, 1))
|
||||
if (binary_log->find_log_pos(&linfo, name, 1))
|
||||
{
|
||||
errmsg = "Could not find target log";
|
||||
goto err;
|
||||
|
Reference in New Issue
Block a user