1 #ifndef RPL_MASTER_H_INCLUDED 2 /* Copyright (c) 2010, 2021, Oracle and/or its affiliates. 3 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License, version 2.0, 6 as published by the Free Software Foundation. 7 8 This program is also distributed with certain software (including 9 but not limited to OpenSSL) that is licensed under separate terms, 10 as designated in a particular file or component or in included license 11 documentation. The authors of MySQL hereby grant you an additional 12 permission to link the program and your derivative works with the 13 separately licensed software that they have included with MySQL. 14 15 This program is distributed in the hope that it will be useful, 16 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 GNU General Public License, version 2.0, for more details. 19 20 You should have received a copy of the GNU General Public License 21 along with this program; if not, write to the Free Software Foundation, 22 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ 23 24 25 #define RPL_MASTER_H_INCLUDED 26 27 #ifdef HAVE_REPLICATION 28 29 #include "my_global.h" 30 #include "mysql_com.h" // HOSTNAME_LENGTH 31 #include "sql_const.h" // MAX_PASSWORD_LENGTH 32 33 class Gtid_set; 34 class String; 35 class THD; 36 37 38 extern bool server_id_supplied; 39 extern int max_binlog_dump_events; 40 extern my_bool opt_sporadic_binlog_dump_fail; 41 extern my_bool opt_show_slave_auth_info; 42 43 typedef struct st_slave_info 44 { 45 uint32 server_id; 46 uint32 rpl_recovery_rank, master_id; 47 char host[HOSTNAME_LENGTH+1]; 48 char user[USERNAME_LENGTH+1]; 49 char password[MAX_PASSWORD_LENGTH+1]; 50 uint16 port; 51 THD* thd; 52 } SLAVE_INFO; 53 54 void init_slave_list(); 55 void end_slave_list(); 56 int register_slave(THD* thd, uchar* packet, size_t packet_length); 57 void unregister_slave(THD* thd, bool only_mine, bool need_lock_slave_list); 58 bool show_slave_hosts(THD* thd); 59 String *get_slave_uuid(THD *thd, String *value); 60 bool show_master_status(THD* thd); 61 bool show_binlogs(THD* thd); 62 void kill_zombie_dump_threads(THD* thd); 63 64 /** 65 Process a COM_BINLOG_DUMP_GTID packet. 66 67 This function parses the packet and then calls mysql_binlog_send. 68 69 @param thd The dump thread. 70 @param packet The COM_BINLOG_DUMP_GTID packet. 71 @param packet_length The length of the packet in bytes. 72 @retval true Error 73 @retval false Success 74 */ 75 bool com_binlog_dump_gtid(THD *thd, char *packet, size_t packet_length); 76 77 /** 78 Process a COM_BINLOG_DUMP packet. 79 80 This function parses the packet and then calls mysql_binlog_send. 81 82 @param thd The dump thread. 83 @param packet The COM_BINLOG_DUMP packet. 84 @param packet_length The length of the packet in bytes. 85 @retval true Error 86 @retval false Success 87 */ 88 bool com_binlog_dump(THD *thd, char *packet, size_t packet_length); 89 90 /** 91 Low-level function where the dump thread iterates over the binary 92 log and sends events to the slave. This function is common for both 93 COM_BINLOG_DUMP and COM_BINLOG_DUMP_GTID. 94 95 @param thd The dump thread. 96 97 @param log_ident The filename of the binary log, as given in the 98 COM_BINLOG_DUMP[_GTID] packet. If this is is an empty string (first 99 character is '\0'), we start with the oldest binary log. 100 101 @param pos The offset in the binary log, as given in the 102 COM_BINLOG_DUMP[_GTID] packet. This must be at least 4 and at most 103 the size of the binary log file. 104 105 @param gtid_set The gtid_set that the slave sent, or NULL if the 106 protocol is COM_BINLOG_DUMP. 107 108 @note This function will start reading at the given (filename, 109 offset), or from the oldest log if filename[0]==0. It will send all 110 events from that position; but if gtid_set!=NULL, it will skip all 111 events in that set. 112 */ 113 void mysql_binlog_send(THD* thd, char* log_ident, my_off_t pos, 114 Gtid_set* gtid_set, uint32 flags); 115 116 bool reset_master(THD* thd); 117 118 #endif /* HAVE_REPLICATION */ 119 120 #endif /* RPL_MASTER_H_INCLUDED */ 121