1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

A slave now can optionally register with the master providing the

info on how to connect to the slave for the clients that connect to
the master, but would like to know where the slaves are


include/mysql_com.h:
  register slaves
mysql-test/mysql-test-run.sh:
  parameters to test slave registration
mysql-test/r/rpl000002.result:
  test of slave registration
mysql-test/t/rpl000002.test:
  test slave registration
sql/mysql_priv.h:
  slave registration
sql/mysqld.cc:
  slave registration
sql/slave.cc:
  slave registration
sql/slave.h:
  slave registration
sql/sql_lex.h:
  slave registration
sql/sql_parse.cc:
  slave registration
sql/sql_repl.cc:
  slave registration
sql/sql_repl.h:
  slave registration
sql/sql_yacc.yy:
  slave registration
This commit is contained in:
unknown
2001-05-30 18:50:56 -06:00
parent f5e06429a6
commit ecba786861
13 changed files with 245 additions and 10 deletions

View File

@ -569,6 +569,52 @@ error:
return 1;
}
int register_slave_on_master(MYSQL* mysql)
{
String packet;
uint len;
char buf[4];
if(!report_host)
return 0;
int4store(buf, server_id);
packet.append(buf, 4);
len = strlen(report_host);
packet.append((char)(uchar)len);
packet.append(report_host, len);
len = strlen(report_user);
packet.append((char)(uchar)len);
packet.append(report_user, len);
if(report_password)
{
len = strlen(report_password);
packet.append((char)(uchar)len);
packet.append(report_password, len);
}
else
{
packet.append((char)0);
}
int2store(buf, (uint16)report_port);
packet.append(buf, 2);
if(mc_simple_command(mysql, COM_REGISTER_SLAVE, (char*)packet.ptr(),
packet.length(), 0))
{
sql_print_error("Error on COM_REGISTER_SLAVE: '%s'",
mc_mysql_error(mysql));
return 1;
}
return 0;
}
int show_master_info(THD* thd)
{
DBUG_ENTER("show_master_info");
@ -1245,6 +1291,12 @@ pthread_handler_decl(handle_slave,arg __attribute__((unused)))
sql_print_error("Slave thread killed while connecting to master");
goto err;
}
// register ourselves with the master
// if fails, this is not fatal - we just print the error message and go
// on with life
thd->proc_info = "Registering slave on master";
register_slave_on_master(mysql);
while (!slave_killed(thd))
{