MySQL 26.7.0
Source Code Documentation
mysql_clone_protocol_imp.h
Go to the documentation of this file.
1/* Copyright (c) 2018, 2026, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
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
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23*/
24
25#ifndef MYSQL_CLONE_PROTOCOL_INCLUDED
26#define MYSQL_CLONE_PROTOCOL_INCLUDED
27
30
31#include "mysql.h"
32#include "sql/sql_class.h"
34#include "sql_common.h"
35
36/**
37 Start and set session and statement key form current thread
38 @param[in,out] thd server session THD
39 @param[in] thread_key PSI key for thread
40 @param[in] statement_key PSI Key for statement
41*/
43 (THD * &thd, PSI_thread_key thread_key,
44 PSI_statement_key statement_key));
45
46/**
47 Finish statement and session
48 @param[in,out] thd server session THD
49*/
51
52/**
53 Get all character set and collations
54 @param[in,out] thd server session THD
55 @param[out] char_sets all character set collations
56 @return error code.
57*/
59 (THD * thd, Mysql_Clone_Values &char_sets));
60
61/**
62 Check if all characters sets are supported by server
63 @param[in,out] thd server session THD
64 @param[in] char_sets all character set collations to validate
65 @return error code.
66*/
68 (THD * thd, Mysql_Clone_Values &char_sets));
69
70/**
71 Get system configuration parameter values.
72 @param[in,out] thd server session THD
73 @param[in,out] configs a list of configuration key value pair
74 keys are input and values are output
75 @return error code.
76*/
78 (THD * thd, Mysql_Clone_Key_Values &configs));
79
80/**
81 Check if configuration parameter values match
82 @param[in,out] thd server session THD
83 @param[in] configs a list of configuration key value pair
84 @return error code.
85*/
87 (THD * thd, Mysql_Clone_Key_Values &configs));
88
90 (const std::string &recipient, const std::string &donor,
91 const bool is_recipient_lts, const bool is_donor_lts,
92 const std::string &recipient_prev_lts));
93
94/**
95 Connect to a remote server and switch to clone protocol
96 @param[in,out] thd server session THD
97 @param[in] host host name to connect to
98 @param[in] port port number to connect to
99 @param[in] user user name on remote host
100 @param[in] passwd password for the user
101 @param[in] ssl_ctx client ssl context
102 @param[out] socket Network socket for the connection
103
104 @return Connection object if successful.
105*/
107 (THD * thd, const char *host, uint32_t port, const char *user,
108 const char *passwd, mysql_clone_ssl_context *ssl_ctx,
110
111/**
112 Execute clone command on remote server
113 @param[in,out] thd local session THD
114 @param[in,out] connection connection object
115 @param[in] set_active set socket active for current THD
116 @param[in] command remote command
117 @param[in] com_buffer data following command
118 @param[in] buffer_length data length
119 @return error code.
120*/
122 (THD * thd, MYSQL *connection, bool set_active, uchar command,
123 uchar *com_buffer, size_t buffer_length));
124
125/**
126 Get response from remote server
127 @param[in,out] thd local session THD
128 @param[in,out] connection connection object
129 @param[in] set_active set socket active for current THD
130 @param[in] timeout timeout in seconds
131 @param[out] packet response packet
132 @param[out] length packet length
133 @param[out] net_length network data length for compressed data
134 @return error code.
135*/
137 (THD * thd, MYSQL *connection, bool set_active, uint32_t timeout,
138 uchar **packet, size_t *length, size_t *net_length));
139
140/**
141 Kill a remote connection
142 @param[in,out] connection connection object
143 @param[in] kill_connection connection to kill
144 @return error code.
145*/
147 (MYSQL * connection, MYSQL *kill_connection));
148
149/**
150 Disconnect from a remote server
151 @param[in,out] thd local session THD
152 @param[in,out] mysql connection object
153 @param[in] is_fatal if closing after fatal error
154 @param[in] clear_error clear any earlier error in session
155*/
157 (THD * thd, MYSQL *mysql, bool is_fatal, bool clear_error));
158
159/**
160 Get error number and message.
161 @param[in,out] thd local session THD
162 @param[out] err_num error number
163 @param[out] err_mesg error message text
164*/
166 (THD * thd, uint32_t *err_num, const char **err_mesg));
167
168/**
169 Get command from client
170 @param[in,out] thd server session THD
171 @param[out] command remote command
172 @param[out] com_buffer data following command
173 @param[out] buffer_length data length
174 @return error code.
175*/
177 (THD * thd, uchar *command, uchar **com_buffer,
178 size_t *buffer_length));
179
180/**
181 Send response to client.
182 @param[in,out] thd server session THD
183 @param[in] secure needs to be sent over secure connection
184 @param[in] packet response packet
185 @param[in] length packet length
186 @return error code.
187*/
189 (THD * thd, bool secure, uchar *packet, size_t length));
190
191/**
192 Send error to client
193 @param[in,out] thd server session THD
194 @param[in] err_cmd error response command
195 @param[in] is_fatal if fatal error
196 @return error code.
197*/
199 (THD * thd, uchar err_cmd, bool is_fatal));
200
201#endif /* MYSQL_CLONE_PROTOCOL_INCLUDED */
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
This service provides functions for clone plugin to connect and interact with remote server's clone p...
std::vector< std::pair< std::string, std::string > > Mysql_Clone_Key_Values
Vector of string Key-Value pairs.
Definition: clone_protocol_service.h:72
std::vector< std::string > Mysql_Clone_Values
Vector of string values.
Definition: clone_protocol_service.h:69
Specifies macros to define Components.
unsigned int PSI_statement_key
Instrumented statement key.
Definition: psi_statement_bits.h:49
unsigned int PSI_thread_key
Instrumented thread key.
Definition: psi_thread_bits.h:50
unsigned char uchar
Definition: my_inttypes.h:52
This file defines the client API to MySQL and also the ABI of the dynamically linked libmysqlclient.
int mysql_clone_send_response(THD *thd, bool secure, uchar *packet, size_t length) noexcept
Send response to client.
Definition: clone_protocol_service.cc:676
int mysql_clone_send_command(THD *thd, MYSQL *connection, bool set_active, uchar command, uchar *com_buffer, size_t buffer_length) noexcept
Execute clone command on remote server.
Definition: clone_protocol_service.cc:440
int mysql_clone_kill(MYSQL *connection, MYSQL *kill_connection) noexcept
Kill a remote connection.
Definition: clone_protocol_service.cc:568
void mysql_clone_finish_statement(THD *thd) noexcept
Finish statement and session.
Definition: clone_protocol_service.cc:132
int mysql_clone_validate_version(const std::string &recipient, const std::string &donor, const bool is_recipient_lts, const bool is_donor_lts, const std::string &recipient_prev_lts) noexcept
Definition: clone_protocol_service.cc:302
void mysql_clone_disconnect(THD *thd, MYSQL *mysql, bool is_fatal, bool clear_error) noexcept
Disconnect from a remote server.
Definition: clone_protocol_service.cc:583
int mysql_clone_get_response(THD *thd, MYSQL *connection, bool set_active, uint32_t timeout, uchar **packet, size_t *length, size_t *net_length) noexcept
Get response from remote server.
Definition: clone_protocol_service.cc:478
int mysql_clone_send_error(THD *thd, uchar err_cmd, bool is_fatal) noexcept
Send error to client.
Definition: clone_protocol_service.cc:704
int mysql_clone_get_charsets(THD *thd, Mysql_Clone_Values &char_sets) noexcept
Get all character set and collations.
Definition: clone_protocol_service.cc:146
void mysql_clone_get_error(THD *thd, uint32_t *err_num, const char **err_mesg) noexcept
Get error number and message.
Definition: clone_protocol_service.cc:611
void mysql_clone_start_statement(THD *&thd, PSI_thread_key thread_key, PSI_statement_key statement_key) noexcept
Start and set session and statement key form current thread.
Definition: clone_protocol_service.cc:91
int mysql_clone_get_configs(THD *thd, Mysql_Clone_Key_Values &configs) noexcept
Get system configuration parameter values.
Definition: clone_protocol_service.cc:230
int mysql_clone_validate_charsets(THD *thd, Mysql_Clone_Values &char_sets) noexcept
Check if all characters sets are supported by server.
Definition: clone_protocol_service.cc:168
MYSQL * mysql_clone_connect(THD *thd, const char *host, uint32_t port, const char *user, const char *passwd, mysql_clone_ssl_context *ssl_ctx, MYSQL_SOCKET *socket) noexcept
Connect to a remote server and switch to clone protocol.
Definition: clone_protocol_service.cc:319
int mysql_clone_get_command(THD *thd, uchar *command, uchar **com_buffer, size_t *buffer_length) noexcept
Get command from client.
Definition: clone_protocol_service.cc:631
int mysql_clone_validate_configs(THD *thd, Mysql_Clone_Key_Values &configs) noexcept
Check if configuration parameter values match.
Definition: clone_protocol_service.cc:249
char * user
Definition: mysqladmin.cc:67
const char * host
Definition: mysqladmin.cc:66
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:76
static bool timeout(bool(*wait_condition)())
Timeout function.
Definition: log0meb.cc:499
Definition: instrumented_condition_variable.h:32
stdx::expected< native_handle_type, error_type > socket(int family, int sock_type, int protocol)
Definition: socket.h:63
void set_active(space_id_t space_id)
Set an undo tablespace active.
Definition: trx0undo_trunc.cc:378
required uint64 port
Definition: replication_asynchronous_connection_failover.proto:33
#define DEFINE_METHOD(retval, name, args)
A macro to ensure method implementation has required properties, that is it does not throw exceptions...
Definition: service_implementation.h:79
An instrumented socket.
Definition: mysql_socket_bits.h:35
Definition: mysql.h:303
Connection parameters including SSL.
Definition: clone_protocol_service.h:53