From 0d5d8d2e7a1debece188f355ecd7b0984ef8d171 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 4 Jul 2019 12:59:18 +0300 Subject: [PATCH] Always print slave host in SHOW SLAVE HOSTS Since the client host can be extracted from the network connection, it can always be printed. This makes it easier to find out where a slave is replicating from. It could also be used to automatically discover slaves that are replicating from a master. --- mysql-test/suite/rpl/r/rpl_show_slave_hosts.result | 4 ++-- sql/repl_failsafe.cc | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/rpl/r/rpl_show_slave_hosts.result b/mysql-test/suite/rpl/r/rpl_show_slave_hosts.result index bd605c6e0fb..79803cca0d0 100644 --- a/mysql-test/suite/rpl/r/rpl_show_slave_hosts.result +++ b/mysql-test/suite/rpl/r/rpl_show_slave_hosts.result @@ -10,11 +10,11 @@ connection master; SHOW SLAVE HOSTS; Server_id Host Port Master_id 3 slave2 SLAVE_PORT 1 -2 SLAVE_PORT 1 +2 localhost SLAVE_PORT 1 connection slave2; include/stop_slave_io.inc connection master; SHOW SLAVE HOSTS; Server_id Host Port Master_id -2 SLAVE_PORT 1 +2 localhost SLAVE_PORT 1 include/rpl_end.inc diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index 18fc3d9431a..7905e112e2e 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -147,6 +147,9 @@ int THD::register_slave(uchar *packet, size_t packet_length) if (!(si->master_id= uint4korr(p))) si->master_id= global_system_variables.server_id; + if (!*si->host) + ::strmake(si->host, main_security_ctx.host_or_ip, sizeof(si->host)); + unregister_slave(); mysql_mutex_lock(&LOCK_thd_data); slave_info= si;