WL#5779: Replication slave interface

Affects: Server-5.5   —   Status: On-Hold   —   Priority: Medium

This is a step towards making replication a library, such that the 5.6 rpl-lib can 
be plugged into the 5.5 core [WL#5675].

In this worklog, we define an interface for the replication slave. We only create 
a class that groups together the functions that the core server needs in order to 
execute slave-related commands. The interface will contain all functions we need, 
but the function prototypes will not be in their final form. In particular, 
unstable structs such as THD will be passed as parameters. In future worklogs, we 
will change the function prototypes.
We define the class Slave. It has the following class functions:

init: Initialize replication slave data. Read master.info and relay-log.info.
Register the function MASTER_POS_WAIT().

end: Finalize and cleanup replication slave.

change_master: Execute CHANGE MASTER statement.

start_slave: Execute START SLAVE statement.

stop_slave: Execute STOP SLAVE statement.

flush_relay_log: Execute FLUSH RELAY LOG statement.

reset_slave: Execute RESET SLAVE statement.

show_slave_status: Execute SHOW SLAVE STATUS statement.

show_relay_log_events: Execute SHOW RELAYLOG EVENTS statement.

execute_binlog_statement: Execute BINLOG statement.
Changes to mysql_execute_command()

For all replication related commands, we will move all handling code to its 
related member function. But the code to check the privileges will be left in 
the server code. It is the server's responsibility to enforce the authorization: 
this will make it impossible to bypass authorization by implementing a 
replication library that removes the privilege checks.

mysql_execute_command(THD *thd)
    if (check_global_access(thd, SUPER_ACL))
      goto error;
    if (rpl_slave.start_slave(thd))
      goto error;
    if (check_global_access(thd, SUPER_ACL))
      goto error;
    if (rpl_slave.stop_slave(thd))
      goto error;

Replication slave
class Slave {
  int init();
  void end();
  int change_master(THD* thd);
  int start_slave(THD* thd);
  int stop_slave(THD* thd);
  int flush_relay_log(THD* thd);
  int reset_slave(THD* thd);
  int show_slave_status(THD* thd);
  int show_relay_log_events(THD* thd);
  int execute_binlog_statement(THD* thd);