Commit 207cd67f authored by Luis Soares's avatar Luis Soares

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.
parent 0b5d3870
-- connection master
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1);
INSERT INTO t1 VALUES (2);
INSERT INTO t1 VALUES (3);
INSERT INTO t1 VALUES (4);
INSERT INTO t1 VALUES (5);
INSERT INTO t1 VALUES (6);
-- echo [MASTER] ********* SOW BINLOG EVENTS IN ... *********
let $binary_log_file= master-bin.000001;
-- source include/show_binlog_events.inc
-- echo [MASTER] ********* SOW BINLOG EVENTS *********
let $binary_log_file= ;
-- source include/show_binlog_events.inc
-- echo [MASTER] ********* SOW BINLOG EVENTS ... LIMIT rows *********
let $binary_log_file= ;
let $binary_log_limit_row= 3;
-- source include/show_binlog_events.inc
-- echo [MASTER] ********* SOW BINLOG EVENTS ... LIMIT offset,rows *********
let $binary_log_file= ;
let $binary_log_limit_row= 3;
let $binary_log_limit_offset= 1;
-- source include/show_binlog_events.inc
# clear show_binlog_event/show_relaylog_events parameters
let $binary_log_file= ;
let $binary_log_limit_row= ;
let $binary_log_limit_offset= ;
-- sync_slave_with_master
-- echo [SLAVE] ********* SOW BINLOG EVENTS IN ... *********
let $binary_log_file= slave-bin.000001;
-- source include/show_binlog_events.inc
-- echo [SLAVE] ********* SOW BINLOG EVENTS *********
let $binary_log_file= ;
-- source include/show_binlog_events.inc
-- echo [SLAVE] ********* SOW BINLOG EVENTS ... LIMIT rows *********
let $binary_log_file= ;
let $binary_log_limit_row= 3;
-- source include/show_binlog_events.inc
-- echo [SLAVE] ********* SOW BINLOG EVENTS ... LIMIT offset,rows *********
let $binary_log_file= ;
let $binary_log_limit_row= 3;
let $binary_log_limit_offset= 1;
-- source include/show_binlog_events.inc
# clear show_binlog_event/show_relaylog_events parameters
let $binary_log_file= ;
let $binary_log_limit_row= ;
let $binary_log_limit_offset= ;
-- echo [SLAVE] ********* SOW RELAYLOG EVENTS IN ... *********
let $binary_log_file= slave-relay-bin.000003;
-- source include/show_relaylog_events.inc
-- echo [SLAVE] ********* SOW RELAYLOG EVENTS *********
let $binary_log_file= ;
-- source include/show_relaylog_events.inc
-- echo [MASTER] ********* SOW RELAYLOG EVENTS ... LIMIT rows *********
let $binary_log_file= slave-relay-bin.000003;
let $binary_log_limit_row= 3;
let $binary_log_limit_offset= ;
-- source include/show_relaylog_events.inc
-- echo [MASTER] ********* SOW RELAYLOG EVENTS ... LIMIT offset,rows *********
let $binary_log_file= slave-relay-bin.000003;
let $binary_log_limit_offset= 1;
let $binary_log_limit_row= 3;
-- source include/show_relaylog_events.inc
FLUSH LOGS;
-- connection master
FLUSH LOGS;
DROP TABLE t1;
# clear show_binlog_event/show_relaylog_events parameters
let $binary_log_file= ;
let $binary_log_limit_row= ;
let $binary_log_limit_offset= ;
-- echo [MASTER] ********* SOW BINLOG EVENTS IN ... *********
let $binary_log_file= master-bin.000002;
-- source include/show_binlog_events.inc
-- echo [MASTER] ********* SOW BINLOG EVENTS *********
let $binary_log_file= ;
-- source include/show_binlog_events.inc
-- sync_slave_with_master
-- echo [SLAVE] ********* SOW BINLOG EVENTS IN ... *********
let $binary_log_file= slave-bin.000002;
-- source include/show_binlog_events.inc
-- echo [SLAVE] ********* SOW BINLOG EVENTS *********
let $binary_log_file= ;
-- source include/show_binlog_events.inc
-- echo [SLAVE] ********* SOW RELAYLOG EVENTS IN ... *********
let $binary_log_file= slave-relay-bin.000005;
-- source include/show_relaylog_events.inc
-- echo [SLAVE] ********* SOW RELAYLOG EVENTS *********
let $binary_log_file= ;
-- source include/show_relaylog_events.inc
# clear show_binlog_event/show_relaylog_events parameters
let $binary_log_name= ;
let $binary_log_limit_row= ;
let $binary_log_limit_offset= ;
# $binlog_start can be set by caller or take a default value
# $binary_log_file the name of the log file show
# $binary_log_limit_row - sets the number of binlog rows to be returned
# $binary_log_limit_offset - sets the offset where to start returning events
let $show_binlog_events= show binlog events;
if (!$binlog_start)
{
# defaults to chop the first event in the binary log
let $binlog_start=106;
}
if (!`SELECT '$binary_log_file' = ''`)
{
let $show_binlog_events= $show_binlog_events in '$binary_log_file';
}
let $show_binlog_events= $show_binlog_events from $binlog_start;
if ($binary_log_limit_row)
{
let $limit= limit;
if ($binary_log_limit_offset)
{
let $limit= $limit $binary_log_limit_offset, ;
}
let $limit= $limit $binary_log_limit_row;
let $show_binlog_events= $show_binlog_events $limit;
}
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR $binlog_start <binlog_start>
--replace_column 2 # 4 # 5 #
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ /file_id=[0-9]+/file_id=#/ /block_len=[0-9]+/block_len=#/
--eval show binlog events from $binlog_start
--eval $show_binlog_events
# $binlog_start can be set by caller or take a default value
# $binary_log_file the name of the log file show
# $binary_log_limit_row - sets the number of binlog rows to be returned
# $binary_log_limit_offset - sets the offset where to start returning events
let $show_binlog_events= show relaylog events;
if (!$binlog_start)
{
# defaults to chop the first event in the binary log
let $binlog_start=106;
}
if (!`SELECT '$binary_log_file' = ''`)
{
let $show_binlog_events= $show_binlog_events in '$binary_log_file';
}
let $show_binlog_events= $show_binlog_events from $binlog_start;
if ($binary_log_limit_row)
{
let $limit= limit;
if ($binary_log_limit_offset)
{
let $limit= $limit $binary_log_limit_offset, ;
}
let $limit= $limit $binary_log_limit_row;
let $show_binlog_events= $show_binlog_events $limit;
}
--replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR $binlog_start <binlog_start>
--replace_column 2 # 4 # 5 #
--replace_regex /\/\* xid=.* \*\//\/* XID *\// /table_id: [0-9]+/table_id: #/ /file_id=[0-9]+/file_id=#/ /block_len=[0-9]+/block_len=#/ /Server ver:.*$/SERVER_VERSION, BINLOG_VERSION/
--eval $show_binlog_events
This diff is collapsed.
stop slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
reset master;
reset slave;
drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9;
start slave;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1);
INSERT INTO t1 VALUES (2);
INSERT INTO t1 VALUES (3);
INSERT INTO t1 VALUES (4);
INSERT INTO t1 VALUES (5);
INSERT INTO t1 VALUES (6);
[MASTER] ********* SOW BINLOG EVENTS IN ... *********
show binlog events in 'master-bin.000001' from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT)
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (1)
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (2)
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (3)
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (4)
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (5)
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (6)
[MASTER] ********* SOW BINLOG EVENTS *********
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT)
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (1)
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (2)
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (3)
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (4)
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (5)
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (6)
[MASTER] ********* SOW BINLOG EVENTS ... LIMIT rows *********
show binlog events from <binlog_start> limit 3;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT)
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (1)
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (2)
[MASTER] ********* SOW BINLOG EVENTS ... LIMIT offset,rows *********
show binlog events from <binlog_start> limit 1, 3;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (1)
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (2)
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (3)
[SLAVE] ********* SOW BINLOG EVENTS IN ... *********
show binlog events in 'slave-bin.000001' from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
slave-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT)
slave-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (1)
slave-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (2)
slave-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (3)
slave-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (4)
slave-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (5)
slave-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (6)
[SLAVE] ********* SOW BINLOG EVENTS *********
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
slave-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT)
slave-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (1)
slave-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (2)
slave-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (3)
slave-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (4)
slave-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (5)
slave-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (6)
[SLAVE] ********* SOW BINLOG EVENTS ... LIMIT rows *********
show binlog events from <binlog_start> limit 3;
Log_name Pos Event_type Server_id End_log_pos Info
slave-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT)
slave-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (1)
slave-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (2)
[SLAVE] ********* SOW BINLOG EVENTS ... LIMIT offset,rows *********
show binlog events from <binlog_start> limit 1, 3;
Log_name Pos Event_type Server_id End_log_pos Info
slave-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (1)
slave-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (2)
slave-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (3)
[SLAVE] ********* SOW RELAYLOG EVENTS IN ... *********
show relaylog events in 'slave-relay-bin.000003' from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
slave-relay-bin.000003 # Rotate # # master-bin.000001;pos=4
slave-relay-bin.000003 # Format_desc # # SERVER_VERSION, BINLOG_VERSION
slave-relay-bin.000003 # Query # # use `test`; CREATE TABLE t1 (a INT)
slave-relay-bin.000003 # Query # # use `test`; INSERT INTO t1 VALUES (1)
slave-relay-bin.000003 # Query # # use `test`; INSERT INTO t1 VALUES (2)
slave-relay-bin.000003 # Query # # use `test`; INSERT INTO t1 VALUES (3)
slave-relay-bin.000003 # Query # # use `test`; INSERT INTO t1 VALUES (4)
slave-relay-bin.000003 # Query # # use `test`; INSERT INTO t1 VALUES (5)
slave-relay-bin.000003 # Query # # use `test`; INSERT INTO t1 VALUES (6)
[SLAVE] ********* SOW RELAYLOG EVENTS *********
show relaylog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
slave-relay-bin.000002 # Rotate # # slave-relay-bin.000003;pos=4
[MASTER] ********* SOW RELAYLOG EVENTS ... LIMIT rows *********
show relaylog events in 'slave-relay-bin.000003' from <binlog_start> limit 3;
Log_name Pos Event_type Server_id End_log_pos Info
slave-relay-bin.000003 # Rotate # # master-bin.000001;pos=4
slave-relay-bin.000003 # Format_desc # # SERVER_VERSION, BINLOG_VERSION
slave-relay-bin.000003 # Query # # use `test`; CREATE TABLE t1 (a INT)
[MASTER] ********* SOW RELAYLOG EVENTS ... LIMIT offset,rows *********
show relaylog events in 'slave-relay-bin.000003' from <binlog_start> limit 1, 3;
Log_name Pos Event_type Server_id End_log_pos Info
slave-relay-bin.000003 # Format_desc # # SERVER_VERSION, BINLOG_VERSION
slave-relay-bin.000003 # Query # # use `test`; CREATE TABLE t1 (a INT)
slave-relay-bin.000003 # Query # # use `test`; INSERT INTO t1 VALUES (1)
FLUSH LOGS;
FLUSH LOGS;
DROP TABLE t1;
[MASTER] ********* SOW BINLOG EVENTS IN ... *********
show binlog events in 'master-bin.000002' from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000002 # Query # # use `test`; DROP TABLE t1
[MASTER] ********* SOW BINLOG EVENTS *********
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
master-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT)
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (1)
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (2)
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (3)
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (4)
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (5)
master-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (6)
master-bin.000001 # Rotate # # master-bin.000002;pos=4
[SLAVE] ********* SOW BINLOG EVENTS IN ... *********
show binlog events in 'slave-bin.000002' from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
slave-bin.000002 # Query # # use `test`; DROP TABLE t1
[SLAVE] ********* SOW BINLOG EVENTS *********
show binlog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
slave-bin.000001 # Query # # use `test`; CREATE TABLE t1 (a INT)
slave-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (1)
slave-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (2)
slave-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (3)
slave-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (4)
slave-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (5)
slave-bin.000001 # Query # # use `test`; INSERT INTO t1 VALUES (6)
slave-bin.000001 # Rotate # # slave-bin.000002;pos=4
[SLAVE] ********* SOW RELAYLOG EVENTS IN ... *********
show relaylog events in 'slave-relay-bin.000005' from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
slave-relay-bin.000005 # Rotate # # master-bin.000002;pos=4
slave-relay-bin.000005 # Rotate # # slave-relay-bin.000006;pos=4
[SLAVE] ********* SOW RELAYLOG EVENTS *********
show relaylog events from <binlog_start>;
Log_name Pos Event_type Server_id End_log_pos Info
slave-relay-bin.000005 # Rotate # # master-bin.000002;pos=4
slave-relay-bin.000005 # Rotate # # slave-relay-bin.000006;pos=4
# BUG#28777 SHOW BINLOG EVENTS does not work on relay log files
#
# GOAL
# ====
#
# Test that SHOW BINLOG EVENTS and the new SHOW RELAYLOG EVENTS works after
# the patch, both on master and slave.
#
# HOW
# ===
#
# This test issues SHOW [BINLOG|RELAYLOG] EVENTS both on master and slave after
# some statements have been issued.
-- source include/master-slave.inc
-- source include/have_binlog_format_row.inc
-- source extra/rpl_tests/rpl_show_relaylog_events.inc
# BUG#28777 SHOW BINLOG EVENTS does not work on relay log files
#
# GOAL
# ====
#
# Test that SHOW BINLOG EVENTS and the new SHOW RELAYLOG EVENTS works after
# the patch, both on master and slave.
#
# HOW
# ===
#
# This test issues SHOW [BINLOG|RELAYLOG] EVENTS both on master and slave after
# some statements have been issued.
-- source include/master-slave.inc
-- source include/have_binlog_format_mixed_or_statement.inc
-- source extra/rpl_tests/rpl_show_relaylog_events.inc
......@@ -429,6 +429,7 @@ static SYMBOL symbols[] = {
{ "REDUNDANT", SYM(REDUNDANT_SYM)},
{ "REFERENCES", SYM(REFERENCES)},
{ "REGEXP", SYM(REGEXP)},
{ "RELAYLOG", SYM(RELAYLOG_SYM)},
{ "RELAY_LOG_FILE", SYM(RELAY_LOG_FILE_SYM)},
{ "RELAY_LOG_POS", SYM(RELAY_LOG_POS_SYM)},
{ "RELAY_THREAD", SYM(RELAY_THREAD)},
......
......@@ -3135,6 +3135,7 @@ SHOW_VAR com_status_vars[]= {
{"show_processlist", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_PROCESSLIST]), SHOW_LONG_STATUS},
{"show_profile", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_PROFILE]), SHOW_LONG_STATUS},
{"show_profiles", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_PROFILES]), SHOW_LONG_STATUS},
{"show_relaylog_events", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_RELAYLOG_EVENTS]), SHOW_LONG_STATUS},
{"show_slave_hosts", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_SLAVE_HOSTS]), SHOW_LONG_STATUS},
{"show_slave_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_SLAVE_STAT]), SHOW_LONG_STATUS},
{"show_status", (char*) offsetof(STATUS_VAR, com_stat[(uint) SQLCOM_SHOW_STATUS]), SHOW_LONG_STATUS},
......
......@@ -174,6 +174,7 @@ sp_get_flags_for_command(LEX *lex)
case SQLCOM_SHOW_AUTHORS:
case SQLCOM_SHOW_BINLOGS:
case SQLCOM_SHOW_BINLOG_EVENTS:
case SQLCOM_SHOW_RELAYLOG_EVENTS:
case SQLCOM_SHOW_CHARSETS:
case SQLCOM_SHOW_COLLATIONS:
case SQLCOM_SHOW_COLUMN_TYPES:
......
......@@ -121,7 +121,7 @@ enum enum_sql_command {
SQLCOM_SHOW_CREATE_TRIGGER,
SQLCOM_ALTER_DB_UPGRADE,
SQLCOM_SHOW_PROFILE, SQLCOM_SHOW_PROFILES,
SQLCOM_SHOW_RELAYLOG_EVENTS,
/*
When a command is added here, be sure it's also added in mysqld.cc
in "struct show_var_st status_vars[]= {" ...
......
......@@ -2319,6 +2319,7 @@ mysql_execute_command(THD *thd)
res = show_slave_hosts(thd);
break;
}
case SQLCOM_SHOW_RELAYLOG_EVENTS: /* fall through */
case SQLCOM_SHOW_BINLOG_EVENTS:
{
if (check_global_access(thd, REPL_SLAVE_ACL))
......
......@@ -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,6 +1412,12 @@ bool mysql_show_binlog_events(THD* thd)
Format_description_log_event *description_event= new
Format_description_log_event(3); /* MySQL 4.0 by default */
DBUG_ASSERT(thd->lex->sql_command == SQLCOM_SHOW_BINLOG_EVENTS ||
thd->lex->sql_command == SQLCOM_SHOW_RELAYLOG_EVENTS);
/* 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
......@@ -1418,7 +1425,17 @@ bool mysql_show_binlog_events(THD* thd)
*/
ha_binlog_wait(thd);
if (mysql_bin_log.is_open())
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;
......
......@@ -930,6 +930,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token REDUNDANT_SYM
%token REFERENCES /* SQL-2003-R */
%token REGEXP
%token RELAYLOG_SYM
%token RELAY_LOG_FILE_SYM
%token RELAY_LOG_POS_SYM
%token RELAY_THREAD
......@@ -9947,6 +9948,11 @@ show_param:
LEX *lex= Lex;
lex->sql_command= SQLCOM_SHOW_BINLOG_EVENTS;
} opt_limit_clause_init
| RELAYLOG_SYM EVENTS_SYM binlog_in binlog_from
{
LEX *lex= Lex;
lex->sql_command= SQLCOM_SHOW_RELAYLOG_EVENTS;
} opt_limit_clause_init
| keys_or_index from_or_in table_ident opt_db where_clause
{
LEX *lex= Lex;
......@@ -11588,6 +11594,7 @@ keyword_sp:
| REDO_BUFFER_SIZE_SYM {}
| REDOFILE_SYM {}
| REDUNDANT_SYM {}
| RELAYLOG_SYM {}
| RELAY_LOG_FILE_SYM {}
| RELAY_LOG_POS_SYM {}
| RELAY_THREAD {}
......
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