#At file:///home/zhl/mysql/rep/5.1/bug28777/
2768 Leonard Zhou 2009-02-05
Bug#28777 show binlog events work on relay log files
added:
mysql-test/suite/rpl/r/rpl_bug28777.result
mysql-test/suite/rpl/t/rpl_bug28777.test
modified:
sql/sql_parse.cc
sql/sql_repl.cc
sql/sql_repl.h
per-file messages:
mysql-test/suite/rpl/r/rpl_bug28777.result
Test result for bug28777
mysql-test/suite/rpl/t/rpl_bug28777.test
Test case for bug28777
sql/sql_parse.cc
Pass Master_info to mysql_show_binlog_events
sql/sql_repl.cc
Search binlog index and relay log index
sql/sql_repl.h
Add Master_info variable
=== added file 'mysql-test/suite/rpl/r/rpl_bug28777.result'
--- a/mysql-test/suite/rpl/r/rpl_bug28777.result 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/r/rpl_bug28777.result 2009-02-05 03:53:06 +0000
@@ -0,0 +1,47 @@
+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;
+==== Initialize ====
+[on master]
+CREATE TABLE t1 (a INT);
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` int(11) DEFAULT NULL
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+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);
+SELECT * FROM t1 ORDER BY a;
+a
+1
+2
+3
+4
+5
+6
+[on slave]
+==== Verify results on slave ====
+show binlog events in 'slave-bin.000001';
+Log_name Pos Event_type Server_id End_log_pos Info
+slave-bin.000001 4 Format_desc 2 106 Server ver: 5.1.32-debug-log, Binlog ver: 4
+slave-bin.000001 106 Query 1 192 use `test`; CREATE TABLE t1 (a INT)
+slave-bin.000001 192 Query 1 280 use `test`; INSERT INTO t1 VALUES (1)
+slave-bin.000001 280 Query 1 368 use `test`; INSERT INTO t1 VALUES (2)
+slave-bin.000001 368 Query 1 456 use `test`; INSERT INTO t1 VALUES (3)
+slave-bin.000001 456 Query 1 544 use `test`; INSERT INTO t1 VALUES (4)
+slave-bin.000001 544 Query 1 632 use `test`; INSERT INTO t1 VALUES (5)
+slave-bin.000001 632 Query 1 720 use `test`; INSERT INTO t1 VALUES (6)
+show binlog events in 'slave-relay-bin.000002';
+Log_name Pos Event_type Server_id End_log_pos Info
+slave-relay-bin.000002 4 Format_desc 2 106 Server ver: 5.1.32-debug-log, Binlog ver: 4
+slave-relay-bin.000002 106 Rotate 2 155 slave-relay-bin.000003;pos=4
+==== Clean up ====
+[on master]
+DROP TABLE t1;
=== added file 'mysql-test/suite/rpl/t/rpl_bug28777.test'
--- a/mysql-test/suite/rpl/t/rpl_bug28777.test 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/rpl/t/rpl_bug28777.test 2009-02-05 03:53:06 +0000
@@ -0,0 +1,37 @@
+source include/have_debug.inc;
+source include/master-slave.inc;
+
+
+--echo ==== Initialize ====
+
+--echo [on master]
+--connection master
+
+CREATE TABLE t1 (a INT);
+SHOW CREATE TABLE t1;
+
+
+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);
+SELECT * FROM t1 ORDER BY a;
+
+--echo [on slave]
+sync_slave_with_master;
+
+
+--echo ==== Verify results on slave ====
+show binlog events in 'slave-bin.000001';
+show binlog events in 'slave-relay-bin.000002';
+
+--echo ==== Clean up ====
+
+--echo [on master]
+connection master;
+DROP TABLE t1;
+
+#--echo [on slave]
+sync_slave_with_master;
=== modified file 'sql/sql_parse.cc'
--- a/sql/sql_parse.cc 2009-01-30 13:44:49 +0000
+++ b/sql/sql_parse.cc 2009-02-05 03:53:06 +0000
@@ -2321,7 +2321,7 @@ mysql_execute_command(THD *thd)
{
if (check_global_access(thd, REPL_SLAVE_ACL))
goto error;
- res = mysql_show_binlog_events(thd);
+ res = mysql_show_binlog_events(thd,active_mi);
break;
}
#endif
=== modified file 'sql/sql_repl.cc'
--- a/sql/sql_repl.cc 2009-01-23 12:22:05 +0000
+++ b/sql/sql_repl.cc 2009-02-05 03:53:06 +0000
@@ -1389,7 +1389,7 @@ int cmp_master_pos(const char* log_file_
@retval FALSE success
@retval TRUE failure
*/
-bool mysql_show_binlog_events(THD* thd)
+bool mysql_show_binlog_events(THD* thd, Master_info* mi)
{
Protocol *protocol= thd->protocol;
List<Item> field_list;
@@ -1438,7 +1438,8 @@ bool mysql_show_binlog_events(THD* thd)
linfo.index_file_offset = 0;
- if (mysql_bin_log.find_log_pos(&linfo, name, 1))
+ if ((mysql_bin_log.find_log_pos(&linfo, name, 1)) &&
+ (mi->rli.relay_log.find_log_pos(&linfo, name, 1)))
{
errmsg = "Could not find target log";
goto err;
=== modified file 'sql/sql_repl.h'
--- a/sql/sql_repl.h 2008-03-14 17:38:54 +0000
+++ b/sql/sql_repl.h 2009-02-05 03:53:06 +0000
@@ -39,7 +39,7 @@ extern my_bool opt_sporadic_binlog_dump_
int start_slave(THD* thd, Master_info* mi, bool net_report);
int stop_slave(THD* thd, Master_info* mi, bool net_report);
bool change_master(THD* thd, Master_info* mi);
-bool mysql_show_binlog_events(THD* thd);
+bool mysql_show_binlog_events(THD* thd, Master_info* mi);
int cmp_master_pos(const char* log_file_name1, ulonglong log_pos1,
const char* log_file_name2, ulonglong log_pos2);
int reset_slave(THD *thd, Master_info* mi);
| Thread |
|---|
| • bzr commit into mysql-5.1-bugteam branch (leonard:2768) Bug#28777 | Leonard Zhou | 13 Feb |