MySQL 8.4.0
Source Code Documentation
mysql_clone_protocol_imp.h
Go to the documentation of this file.
1/* Copyright (c) 2018, 2024, 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
89/**
90 Connect to a remote server and switch to clone protocol
91 @param[in,out] thd server session THD
92 @param[in] host host name to connect to
93 @param[in] port port number to connect to
94 @param[in] user user name on remote host
95 @param[in] passwd password for the user
96 @param[in] ssl_ctx client ssl context
97 @param[out] socket Network socket for the connection
98
99 @return Connection object if successful.
100*/
102 (THD * thd, const char *host, uint32_t port, const char *user,
103 const char *passwd, mysql_clone_ssl_context *ssl_ctx,
105
106/**
107 Execute clone command on remote server
108 @param[in,out] thd local session THD
109 @param[in,out] connection connection object
110 @param[in] set_active set socket active for current THD
111 @param[in] command remote command
112 @param[in] com_buffer data following command
113 @param[in] buffer_length data length
114 @return error code.
115*/
117 (THD * thd, MYSQL *connection, bool set_active, uchar command,
118 uchar *com_buffer, size_t buffer_length));
119
120/**
121 Get response from remote server
122 @param[in,out] thd local session THD
123 @param[in,out] connection connection object
124 @param[in] set_active set socket active for current THD
125 @param[in] timeout timeout in seconds
126 @param[out] packet response packet
127 @param[out] length packet length
128 @param[out] net_length network data length for compressed data
129 @return error code.
130*/
132 (THD * thd, MYSQL *connection, bool set_active, uint32_t timeout,
133 uchar **packet, size_t *length, size_t *net_length));
134
135/**
136 Kill a remote connection
137 @param[in,out] connection connection object
138 @param[in] kill_connection connection to kill
139 @return error code.
140*/
142 (MYSQL * connection, MYSQL *kill_connection));
143
144/**
145 Disconnect from a remote server
146 @param[in,out] thd local session THD
147 @param[in,out] mysql connection object
148 @param[in] is_fatal if closing after fatal error
149 @param[in] clear_error clear any earlier error in session
150*/
152 (THD * thd, MYSQL *mysql, bool is_fatal, bool clear_error));
153
154/**
155 Get error number and message.
156 @param[in,out] thd local session THD
157 @param[out] err_num error number
158 @param[out] err_mesg error message text
159*/
161 (THD * thd, uint32_t *err_num, const char **err_mesg));
162
163/**
164 Get command from client
165 @param[in,out] thd server session THD
166 @param[out] command remote command
167 @param[out] com_buffer data following command
168 @param[out] buffer_length data length
169 @return error code.
170*/
172 (THD * thd, uchar *command, uchar **com_buffer,
173 size_t *buffer_length));
174
175/**
176 Send response to client.
177 @param[in,out] thd server session THD
178 @param[in] secure needs to be sent over secure connection
179 @param[in] packet response packet
180 @param[in] length packet length
181 @return error code.
182*/
184 (THD * thd, bool secure, uchar *packet, size_t length));
185
186/**
187 Send error to client
188 @param[in,out] thd server session THD
189 @param[in] err_cmd error response command
190 @param[in] is_fatal if fatal error
191 @return error code.
192*/
194 (THD * thd, uchar err_cmd, bool is_fatal));
195
196#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:794
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:558
int mysql_clone_kill(MYSQL *connection, MYSQL *kill_connection) noexcept
Kill a remote connection.
Definition: clone_protocol_service.cc:686
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:701
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:596
int mysql_clone_send_error(THD *thd, uchar err_cmd, bool is_fatal) noexcept
Send error to client.
Definition: clone_protocol_service.cc:822
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:729
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:437
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:749
int mysql_clone_validate_configs(THD *thd, Mysql_Clone_Key_Values &configs) noexcept
Check if configuration parameter values match.
Definition: clone_protocol_service.cc:377
char * user
Definition: mysqladmin.cc:66
const char * host
Definition: mysqladmin.cc:65
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:1137
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
command
Definition: version_token.cc:280