List:Commits« Previous MessageNext Message »
From:Luis Soares Date:May 13 2009 11:04am
Subject:bzr commit into mysql-6.0-rpl branch (luis.soares:2844) Bug#28777
View as plain text  
#At file:///home/lsoares/Workspace/mysql-server/bugfix/b28777/6.0-rpl/ based on revid:aelkin@stripped

 2844 Luis Soares	2009-05-13
      BUG#28777: SHOW BINLOG EVENTS does not work on relay log files
            
      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.

    added:
      mysql-test/extra/rpl_tests/rpl_show_relaylog_events.inc
      mysql-test/include/show_relaylog_events.inc
      mysql-test/suite/rpl/r/rpl_row_show_relaylog_events.result
      mysql-test/suite/rpl/r/rpl_stm_mix_show_relaylog_events.result
      mysql-test/suite/rpl/t/rpl_row_show_relaylog_events.test
      mysql-test/suite/rpl/t/rpl_stm_mix_show_relaylog_events.test
    modified:
      mysql-test/include/show_binlog_events.inc
      sql/lex.h
      sql/mysqld.cc
      sql/sp_head.cc
      sql/sql_lex.h
      sql/sql_parse.cc
      sql/sql_repl.cc
      sql/sql_yacc.yy
=== added file 'mysql-test/extra/rpl_tests/rpl_show_relaylog_events.inc'
--- a/mysql-test/extra/rpl_tests/rpl_show_relaylog_events.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/extra/rpl_tests/rpl_show_relaylog_events.inc	2009-05-13 11:04:33 +0000
@@ -0,0 +1,121 @@
+-- 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= ;

=== modified file 'mysql-test/include/show_binlog_events.inc'
--- a/mysql-test/include/show_binlog_events.inc	2008-09-06 07:22:50 +0000
+++ b/mysql-test/include/show_binlog_events.inc	2009-05-13 11:04:33 +0000
@@ -1,10 +1,35 @@
 # $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=107;
 }
+
+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

=== added file 'mysql-test/include/show_relaylog_events.inc'
--- a/mysql-test/include/show_relaylog_events.inc	1970-01-01 00:00:00 +0000
+++ b/mysql-test/include/show_relaylog_events.inc	2009-05-13 11:04:33 +0000
@@ -0,0 +1,35 @@
+# $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=107;
+}
+
+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

=== added file 'mysql-test/suite/rpl/r/rpl_row_show_relaylog_events.result'
--- a/mysql-test/suite/rpl/r/rpl_row_show_relaylog_events.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_row_show_relaylog_events.result	2009-05-13 11:04:33 +0000
@@ -0,0 +1,274 @@
+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`; BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
+[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`; BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
+[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`; BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+[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`; BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+[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`; BEGIN
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	use `test`; COMMIT
+slave-bin.000001	#	Query	#	#	use `test`; BEGIN
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	use `test`; COMMIT
+slave-bin.000001	#	Query	#	#	use `test`; BEGIN
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	use `test`; COMMIT
+slave-bin.000001	#	Query	#	#	use `test`; BEGIN
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	use `test`; COMMIT
+slave-bin.000001	#	Query	#	#	use `test`; BEGIN
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	use `test`; COMMIT
+slave-bin.000001	#	Query	#	#	use `test`; BEGIN
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	use `test`; COMMIT
+[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`; BEGIN
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	use `test`; COMMIT
+slave-bin.000001	#	Query	#	#	use `test`; BEGIN
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	use `test`; COMMIT
+slave-bin.000001	#	Query	#	#	use `test`; BEGIN
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	use `test`; COMMIT
+slave-bin.000001	#	Query	#	#	use `test`; BEGIN
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	use `test`; COMMIT
+slave-bin.000001	#	Query	#	#	use `test`; BEGIN
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	use `test`; COMMIT
+slave-bin.000001	#	Query	#	#	use `test`; BEGIN
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	use `test`; COMMIT
+[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`; BEGIN
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+[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`; BEGIN
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+[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`; BEGIN
+slave-relay-bin.000003	#	Table_map	#	#	table_id: # (test.t1)
+slave-relay-bin.000003	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-relay-bin.000003	#	Query	#	#	use `test`; COMMIT
+slave-relay-bin.000003	#	Query	#	#	use `test`; BEGIN
+slave-relay-bin.000003	#	Table_map	#	#	table_id: # (test.t1)
+slave-relay-bin.000003	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-relay-bin.000003	#	Query	#	#	use `test`; COMMIT
+slave-relay-bin.000003	#	Query	#	#	use `test`; BEGIN
+slave-relay-bin.000003	#	Table_map	#	#	table_id: # (test.t1)
+slave-relay-bin.000003	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-relay-bin.000003	#	Query	#	#	use `test`; COMMIT
+slave-relay-bin.000003	#	Query	#	#	use `test`; BEGIN
+slave-relay-bin.000003	#	Table_map	#	#	table_id: # (test.t1)
+slave-relay-bin.000003	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-relay-bin.000003	#	Query	#	#	use `test`; COMMIT
+slave-relay-bin.000003	#	Query	#	#	use `test`; BEGIN
+slave-relay-bin.000003	#	Table_map	#	#	table_id: # (test.t1)
+slave-relay-bin.000003	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-relay-bin.000003	#	Query	#	#	use `test`; COMMIT
+slave-relay-bin.000003	#	Query	#	#	use `test`; BEGIN
+slave-relay-bin.000003	#	Table_map	#	#	table_id: # (test.t1)
+slave-relay-bin.000003	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-relay-bin.000003	#	Query	#	#	use `test`; COMMIT
+[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`; BEGIN
+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`; BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
+master-bin.000001	#	Query	#	#	use `test`; BEGIN
+master-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+master-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+master-bin.000001	#	Query	#	#	use `test`; COMMIT
+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`; BEGIN
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	use `test`; COMMIT
+slave-bin.000001	#	Query	#	#	use `test`; BEGIN
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	use `test`; COMMIT
+slave-bin.000001	#	Query	#	#	use `test`; BEGIN
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	use `test`; COMMIT
+slave-bin.000001	#	Query	#	#	use `test`; BEGIN
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	use `test`; COMMIT
+slave-bin.000001	#	Query	#	#	use `test`; BEGIN
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	use `test`; COMMIT
+slave-bin.000001	#	Query	#	#	use `test`; BEGIN
+slave-bin.000001	#	Table_map	#	#	table_id: # (test.t1)
+slave-bin.000001	#	Write_rows	#	#	table_id: # flags: STMT_END_F
+slave-bin.000001	#	Query	#	#	use `test`; COMMIT
+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

=== added file 'mysql-test/suite/rpl/r/rpl_stm_mix_show_relaylog_events.result'
--- a/mysql-test/suite/rpl/r/rpl_stm_mix_show_relaylog_events.result	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_stm_mix_show_relaylog_events.result	2009-05-13 11:04:33 +0000
@@ -0,0 +1,148 @@
+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

=== added file 'mysql-test/suite/rpl/t/rpl_row_show_relaylog_events.test'
--- a/mysql-test/suite/rpl/t/rpl_row_show_relaylog_events.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_row_show_relaylog_events.test	2009-05-13 11:04:33 +0000
@@ -0,0 +1,18 @@
+# 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

=== added file 'mysql-test/suite/rpl/t/rpl_stm_mix_show_relaylog_events.test'
--- a/mysql-test/suite/rpl/t/rpl_stm_mix_show_relaylog_events.test	1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_stm_mix_show_relaylog_events.test	2009-05-13 11:04:33 +0000
@@ -0,0 +1,18 @@
+# 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

=== modified file 'sql/lex.h'
--- a/sql/lex.h	2009-03-09 14:00:03 +0000
+++ b/sql/lex.h	2009-05-13 11:04:33 +0000
@@ -444,6 +444,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)},

=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc	2009-04-22 22:12:25 +0000
+++ b/sql/mysqld.cc	2009-05-13 11:04:33 +0000
@@ -3279,6 +3279,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},

=== modified file 'sql/sp_head.cc'
--- a/sql/sp_head.cc	2009-04-13 13:24:28 +0000
+++ b/sql/sp_head.cc	2009-05-13 11:04:33 +0000
@@ -175,6 +175,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_CONTRIBUTORS:

=== modified file 'sql/sql_lex.h'
--- a/sql/sql_lex.h	2009-03-19 16:42:23 +0000
+++ b/sql/sql_lex.h	2009-05-13 11:04:33 +0000
@@ -123,6 +123,7 @@ enum enum_sql_command {
 #endif
   SQLCOM_SHOW_PROFILE, SQLCOM_SHOW_PROFILES,
   SQLCOM_SIGNAL, SQLCOM_RESIGNAL,
+  SQLCOM_SHOW_RELAYLOG_EVENTS, 
 
   /*
     When a command is added here, be sure it's also added in mysqld.cc

=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc	2009-04-22 22:12:25 +0000
+++ b/sql/sql_parse.cc	2009-05-13 11:04:33 +0000
@@ -2353,6 +2353,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))

=== modified file 'sql/sql_repl.cc'
--- a/sql/sql_repl.cc	2009-04-21 13:49:02 +0000
+++ b/sql/sql_repl.cc	2009-05-13 11:04:33 +0000
@@ -1689,6 +1689,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);
@@ -1699,14 +1700,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;
@@ -1714,7 +1731,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;
 
@@ -1724,13 +1741,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;

=== modified file 'sql/sql_yacc.yy'
--- a/sql/sql_yacc.yy	2009-04-01 21:36:07 +0000
+++ b/sql/sql_yacc.yy	2009-05-13 11:04:33 +0000
@@ -1033,6 +1033,7 @@ bool my_yyoverflow(short **a, YYSTYPE **
 %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
@@ -10693,6 +10694,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;
@@ -12316,6 +12322,7 @@ keyword_sp:
         | REDO_BUFFER_SIZE_SYM     {}
         | REDOFILE_SYM             {}
         | REDUNDANT_SYM            {}
+        | RELAYLOG_SYM             {}
         | RELAY_LOG_FILE_SYM       {}
         | RELAY_LOG_POS_SYM        {}
         | RELAY_THREAD             {}


Attachment: [text/bzr-bundle] bzr/luis.soares@sun.com-20090513110433-4z0qqlp144dy2uzp.bundle
Thread
bzr commit into mysql-6.0-rpl branch (luis.soares:2844) Bug#28777Luis Soares13 May
  • Re: bzr commit into mysql-6.0-rpl branch (luis.soares:2844) Bug#28777He Zhenxing14 May