summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mäkelä <markus456@gmail.com>2019-07-04 12:59:18 +0300
committerRobert Bindar <robert@mariadb.org>2019-07-29 13:38:29 +0300
commit0d5d8d2e7a1debece188f355ecd7b0984ef8d171 (patch)
tree08643ba3c951b20c37bd6728efbce37c4eb5487a
parent1e9aa46dc34de23c78a4c897ad3977aa10fbcf95 (diff)
downloadmariadb-git-0d5d8d2e7a1debece188f355ecd7b0984ef8d171.tar.gz
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.
-rw-r--r--mysql-test/suite/rpl/r/rpl_show_slave_hosts.result4
-rw-r--r--sql/repl_failsafe.cc3
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;