MySQL 9.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
93/**
94 Connect to a remote server and switch to clone protocol
95 @param[in,out] thd server session THD
96 @param[in] host host name to connect to
97 @param[in] port port number to connect to
98 @param[in] user user name on remote host
99 @param[in] passwd password for the user
100 @param[in] ssl_ctx client ssl context
101 @param[out] socket Network socket for the connection
102
103 @return Connection object if successful.
104*/
106 (THD * thd, const char *host, uint32_t port, const char *user,
107 const char *passwd, mysql_clone_ssl_context *ssl_ctx,
109
110/**
111 Execute clone command on remote server
112 @param[in,out] thd local session THD
113 @param[in,out] connection connection object
114 @param[in] set_active set socket active for current THD
115 @param[in] command remote command
116 @param[in] com_buffer data following command
117 @param[in] buffer_length data length
118 @return error code.
119*/
121 (THD * thd, MYSQL *connection, bool set_active, uchar command,
122 uchar *com_buffer, size_t buffer_length));
123
124/**
125 Get response from remote server
126 @param[in,out] thd local session THD
127 @param[in,out] connection connection object
128 @param[in] set_active set socket active for current THD
129 @param[in] timeout timeout in seconds
130 @param[out] packet response packet
131 @param[out] length packet length
132 @param[out] net_length network data length for compressed data
133 @return error code.
134*/
136 (THD * thd, MYSQL *connection, bool set_active, uint32_t timeout,
137 uchar **packet, size_t *length, size_t *net_length));
138
139/**
140 Kill a remote connection
141 @param[in,out] connection connection object
142 @param[in] kill_connection connection to kill
143 @return error code.
144*/
146 (MYSQL * connection, MYSQL *kill_connection));
147
148/**
149 Disconnect from a remote server
150 @param[in,out] thd local session THD
151 @param[in,out] mysql connection object
152 @param[in] is_fatal if closing after fatal error
153 @param[in] clear_error clear any earlier error in session
154*/
156 (THD * thd, MYSQL *mysql, bool is_fatal, bool clear_error));
157
158/**
159 Get error number and message.
160 @param[in,out] thd local session THD
161 @param[out] err_num error number
162 @param[out] err_mesg error message text
163*/
165 (THD * thd, uint32_t *err_num, const char **err_mesg));
166
167/**
168 Get command from client
169 @param[in,out] thd server session THD
170 @param[out] command remote command
171 @param[out] com_buffer data following command
172 @param[out] buffer_length data length
173 @return error code.
174*/
176 (THD * thd, uchar *command, uchar **com_buffer,
177 size_t *buffer_length));
178
179/**
180 Send response to client.
181 @param[in,out] thd server session THD
182 @param[in] secure needs to be sent over secure connection
183 @param[in] packet response packet
184 @param[in] length packet length
185 @return error code.
186*/
188 (THD * thd, bool secure, uchar *packet, size_t length));
189
190/**
191 Send error to client
192 @param[in,out] thd server session THD
193 @param[in] err_cmd error response command
194 @param[in] is_fatal if fatal error
195 @return error code.
196*/
198 (THD * thd, uchar err_cmd, bool is_fatal));
199
200#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:670
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:434
int mysql_clone_validate_version(const std::string &recipient, const std::string &donor, const bool is_recipient_lts, const bool is_donor_lts) noexcept
Definition: clone_protocol_service.cc:301
int mysql_clone_kill(MYSQL *connection, MYSQL *kill_connection) noexcept
Kill a remote connection.
Definition: clone_protocol_service.cc:562
void mysql_clone_finish_statement(THD *thd) noexcept
Finish statement and session.
Definition: clone_protocol_service.cc:132
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:577
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:472
int mysql_clone_send_error(THD *thd, uchar err_cmd, bool is_fatal) noexcept
Send error to client.
Definition: clone_protocol_service.cc:698
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:605
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:313
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:625
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:498
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: trx0purge.cc:1161
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:300
Connection parameters including SSL.
Definition: clone_protocol_service.h:53