MySQL 8.0.32
Source Code Documentation
rpl_source.h
Go to the documentation of this file.
1#ifndef RPL_SOURCE_H_INCLUDED
2#define RPL_SOURCE_H_INCLUDED
3
4/* Copyright (c) 2010, 2022, Oracle and/or its affiliates.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License, version 2.0,
8 as published by the Free Software Foundation.
9
10 This program is also distributed with certain software (including
11 but not limited to OpenSSL) that is licensed under separate terms,
12 as designated in a particular file or component or in included license
13 documentation. The authors of MySQL hereby grant you an additional
14 permission to link the program and your derivative works with the
15 separately licensed software that they have included with MySQL.
16
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License, version 2.0, for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
25
26#include <stddef.h>
27#include <string> // std::string
28
29#include "libbinlogevents/include/uuid.h" // UUID
30#include "my_hostname.h" // HOSTNAME_LENGTH
31#include "my_inttypes.h"
32#include "my_thread_local.h" // my_thread_id
33#include "mysql_com.h" // USERNAME_LENGTH
34#include "sql/sql_const.h" // MAX_PASSWORD_LENGTH
35
36class Gtid_set;
37class String;
38class THD;
39
40extern bool server_id_supplied;
41extern int max_binlog_dump_events;
44
55};
56
57int register_replica(THD *thd, uchar *packet, size_t packet_length);
58void unregister_replica(THD *thd, bool only_mine, bool need_lock_slave_list);
59bool show_replicas(THD *thd);
60String *get_replica_uuid(THD *thd, String *value);
61bool show_master_status(THD *thd);
62bool show_binlogs(THD *thd);
64
65/**
66 Process a COM_BINLOG_DUMP_GTID packet.
67
68 This function parses the packet and then calls mysql_binlog_send.
69
70 @param thd The dump thread.
71 @param packet The COM_BINLOG_DUMP_GTID packet.
72 @param packet_length The length of the packet in bytes.
73 @retval true Error
74 @retval false Success
75*/
76bool com_binlog_dump_gtid(THD *thd, char *packet, size_t packet_length);
77
78/**
79 Process a COM_BINLOG_DUMP packet.
80
81 This function parses the packet and then calls mysql_binlog_send.
82
83 @param thd The dump thread.
84 @param packet The COM_BINLOG_DUMP packet.
85 @param packet_length The length of the packet in bytes.
86 @retval true Error
87 @retval false Success
88*/
89bool com_binlog_dump(THD *thd, char *packet, size_t packet_length);
90
91/**
92 Low-level function where the dump thread iterates over the binary
93 log and sends events to the slave. This function is common for both
94 COM_BINLOG_DUMP and COM_BINLOG_DUMP_GTID.
95
96 @param thd The dump thread.
97
98 @param log_ident The filename of the binary log, as given in the
99 COM_BINLOG_DUMP[_GTID] packet. If this is is an empty string (first
100 character is '\0'), we start with the oldest binary log.
101
102 @param pos The offset in the binary log, as given in the
103 COM_BINLOG_DUMP[_GTID] packet. This must be at least 4 and at most
104 the size of the binary log file.
105
106 @param gtid_set The gtid_set that the slave sent, or NULL if the
107 protocol is COM_BINLOG_DUMP.
108
109 @param flags flags in COM_BINLOG_DUMP[_GTID] packets.
110
111 @note This function will start reading at the given (filename,
112 offset), or from the oldest log if filename[0]==0. It will send all
113 events from that position; but if gtid_set!=NULL, it will skip all
114 events in that set.
115*/
116void mysql_binlog_send(THD *thd, char *log_ident, my_off_t pos,
117 Gtid_set *gtid_set, uint32 flags);
118
119bool reset_master(THD *thd, bool unlock_read_lock);
120
121class user_var_entry;
122/**
123 Read a user variable that may exist under two different names.
124
125 @param thd The session to read from.
126
127 @param alt1 The first variable name alternative.
128
129 @param alt2 The second variable name alternative.
130
131 @retval If there exists a user variable in the current session with
132 the first name, return that. Otherwise, if the second one exists,
133 return that. Otherwise, return NULL.
134*/
136 const std::string alt1,
137 const std::string alt2);
138
139#endif /* RPL_SOURCE_H_INCLUDED */
Represents a set of GTIDs.
Definition: rpl_gtid.h:1454
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:166
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:33
Definition: item_func.h:2974
bool server_id_supplied
Definition: mysqld.cc:1181
static int flags[50]
Definition: hp_test1.cc:39
Common definition used by mysys, performance schema and server & client.
static constexpr int HOSTNAME_LENGTH
Definition: my_hostname.h:42
Some integer typedefs for easier portability.
ulonglong my_off_t
Definition: my_inttypes.h:71
unsigned char uchar
Definition: my_inttypes.h:51
uint16_t uint16
Definition: my_inttypes.h:64
uint32_t uint32
Definition: my_inttypes.h:66
uint32 my_thread_id
Definition: my_thread_local.h:33
Common definition between mysql server & client.
#define USERNAME_LENGTH
Definition: mysql_com.h:68
void mysql_binlog_send(THD *thd, char *log_ident, my_off_t pos, Gtid_set *gtid_set, uint32 flags)
Low-level function where the dump thread iterates over the binary log and sends events to the slave.
Definition: rpl_source.cc:993
const user_var_entry * get_user_var_from_alternatives(const THD *thd, const std::string alt1, const std::string alt2)
Read a user variable that may exist under two different names.
Definition: rpl_source.cc:1000
bool show_master_status(THD *thd)
Execute a SHOW MASTER STATUS statement.
Definition: rpl_source.cc:1206
bool com_binlog_dump(THD *thd, char *packet, size_t packet_length)
Process a COM_BINLOG_DUMP packet.
Definition: rpl_source.cc:896
int max_binlog_dump_events
Definition: rpl_source.cc:80
bool show_binlogs(THD *thd)
Execute a SHOW BINARY LOGS statement.
Definition: rpl_source.cc:1267
void unregister_replica(THD *thd, bool only_mine, bool need_lock_slave_list)
Definition: rpl_source.cc:168
void kill_zombie_dump_threads(THD *thd)
Definition: rpl_source.cc:1095
int register_replica(THD *thd, uchar *packet, size_t packet_length)
Register slave in 'slave_list' hash table.
Definition: rpl_source.cc:112
bool com_binlog_dump_gtid(THD *thd, char *packet, size_t packet_length)
Process a COM_BINLOG_DUMP_GTID packet.
Definition: rpl_source.cc:936
bool opt_show_replica_auth_info
Definition: mysqld.cc:1223
String * get_replica_uuid(THD *thd, String *value)
An auxiliary function extracts slave UUID.
Definition: rpl_source.cc:1019
bool opt_sporadic_binlog_dump_fail
Definition: rpl_source.cc:81
bool show_replicas(THD *thd)
Execute a SHOW REPLICAS / SHOW SLAVE HOSTS statement.
Definition: rpl_source.cc:193
bool reset_master(THD *thd, bool unlock_read_lock)
Execute a RESET MASTER statement.
Definition: rpl_source.cc:1135
File containing constants that can be used throughout the server.
Definition: rpl_source.h:45
char host[HOSTNAME_LENGTH+1]
Definition: rpl_source.h:48
my_thread_id thd_id
Definition: rpl_source.h:52
uint16 port
Definition: rpl_source.h:51
char user[USERNAME_LENGTH+1]
Definition: rpl_source.h:49
uint32 master_id
Definition: rpl_source.h:47
binary_log::Uuid replica_uuid
Definition: rpl_source.h:53
uint32 rpl_recovery_rank
Definition: rpl_source.h:47
char password[MAX_PASSWORD_LENGTH+1]
Definition: rpl_source.h:50
bool valid_replica_uuid
Definition: rpl_source.h:54
uint32 server_id
Definition: rpl_source.h:46
This is a POD.
Definition: uuid.h:60
#define MAX_PASSWORD_LENGTH
Definition: validate_password.cc:63