MySQL  8.0.19
Source Code Documentation
mysql_clone_protocol.h
Go to the documentation of this file.
1 /* Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
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 also distributed 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 included with MySQL.
13 
14  This program is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License, version 2.0, for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with this program; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23 
24 #ifndef MYSQL_CLONE_PROTOCOL_INCLUDED
25 #define MYSQL_CLONE_PROTOCOL_INCLUDED
26 
29 
30 #include "mysql.h"
31 #include "sql/sql_class.h"
33 #include "sql_common.h"
34 
35 /**
36  Start and set session and statement key form current thread
37  @param[in,out] thd server session THD
38  @param[in] thread_key PSI key for thread
39  @param[in] statement_key PSI Key for statement
40 */
42  (THD * &thd, PSI_thread_key thread_key,
43  PSI_statement_key statement_key));
44 
45 /**
46  Finish statement and session
47  @param[in,out] thd server session THD
48 */
50 
51 /**
52  Get all character set and collations
53  @param[in,out] thd server session THD
54  @param[out] char_sets all character set collations
55  @return error code.
56 */
58  (THD * thd, Mysql_Clone_Values &char_sets));
59 
60 /**
61  Check if all characters sets are supported by server
62  @param[in,out] thd server session THD
63  @param[in] char_sets all character set collations to validate
64  @return error code.
65 */
67  (THD * thd, Mysql_Clone_Values &char_sets));
68 
69 /**
70  Get system configuration parameter values.
71  @param[in,out] thd server session THD
72  @param[in,out] configs a list of configuration key value pair
73  keys are input and values are output
74  @return error code.
75 */
77  (THD * thd, Mysql_Clone_Key_Values &configs));
78 
79 /**
80  Check if configuration parameter values match
81  @param[in,out] thd server session THD
82  @param[in] configs a list of configuration key value pair
83  @return error code.
84 */
86  (THD * thd, Mysql_Clone_Key_Values &configs));
87 
88 /**
89  Connect to a remote server and switch to clone protocol
90  @param[in,out] thd server session THD
91  @param[in] host host name to connect to
92  @param[in] port port number to connect to
93  @param[in] user user name on remote host
94  @param[in] passwd password for the user
95  @param[in] ssl_ctx client ssl context
96  @param[out] socket Network socket for the connection
97 
98  @return Connection object if successful.
99 */
101  (THD * thd, const char *host, uint32_t port, const char *user,
102  const char *passwd, mysql_clone_ssl_context *ssl_ctx,
103  MYSQL_SOCKET *socket));
104 
105 /**
106  Execute clone command on remote server
107  @param[in,out] thd local session THD
108  @param[in,out] connection connection object
109  @param[in] set_active set socket active for current THD
110  @param[in] command remote command
111  @param[in] com_buffer data following command
112  @param[in] buffer_length data length
113  @return error code.
114 */
116  (THD * thd, MYSQL *connection, bool set_active, uchar command,
117  uchar *com_buffer, size_t buffer_length));
118 
119 /**
120  Get response from remote server
121  @param[in,out] thd local session THD
122  @param[in,out] connection connection object
123  @param[in] set_active set socket active for current THD
124  @param[in] timeout timeout in seconds
125  @param[out] packet response packet
126  @param[out] length packet length
127  @param[out] net_length network data length for compressed data
128  @return error code.
129 */
131  (THD * thd, MYSQL *connection, bool set_active, uint32_t timeout,
132  uchar **packet, size_t *length, size_t *net_length));
133 
134 /**
135  Kill a remote connection
136  @param[in,out] connection connection object
137  @param[in] kill_connection connection to kill
138  @return error code.
139 */
141  (MYSQL * connection, MYSQL *kill_connection));
142 
143 /**
144  Disconnect from a remote server
145  @param[in,out] thd local session THD
146  @param[in,out] mysql connection object
147  @param[in] is_fatal if closing after fatal error
148  @param[in] clear_error clear any earlier error in session
149 */
151  (THD * thd, MYSQL *mysql, bool is_fatal, bool clear_error));
152 
153 /**
154  Get error number and message.
155  @param[in,out] thd local session THD
156  @param[out] err_num error number
157  @param[out] err_mesg error message text
158 */
160  (THD * thd, uint32_t *err_num, const char **err_mesg));
161 
162 /**
163  Get command from client
164  @param[in,out] thd server session THD
165  @param[out] command remote command
166  @param[out] com_buffer data following command
167  @param[out] buffer_length data length
168  @return error code.
169 */
171  (THD * thd, uchar *command, uchar **com_buffer,
172  size_t *buffer_length));
173 
174 /**
175  Send response to client.
176  @param[in,out] thd server session THD
177  @param[in] secure needs to be sent over secure connection
178  @param[in] packet response packet
179  @param[in] length packet length
180  @return error code.
181 */
183  (THD * thd, bool secure, uchar *packet, size_t length));
184 
185 /**
186  Send error to client
187  @param[in,out] thd server session THD
188  @param[in] err_cmd error response command
189  @param[in] is_fatal if fatal error
190  @return error code.
191 */
193  (THD * thd, uchar err_cmd, bool is_fatal));
194 
195 #endif /* MYSQL_CLONE_PROTOCOL_INCLUDED */
sql_class.h
THD
Definition: sql_class.h:764
mysql_clone_send_command
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:361
mysql_clone_get_command
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:537
sql_common.h
mysql_clone_validate_configs
int mysql_clone_validate_configs(THD *thd, Mysql_Clone_Key_Values &configs) noexcept
Check if configuration parameter values match.
Definition: clone_protocol_service.cc:199
clone_protocol_service.h
mysql.h
mysql_clone_get_error
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:517
mysql_clone_start_statement
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:48
host
const char * host
Definition: mysqladmin.cc:58
mysql
static MYSQL mysql
Definition: mysql.cc:152
mysql_clone_finish_statement
void mysql_clone_finish_statement(THD *thd) noexcept
Finish statement and session.
Definition: clone_protocol_service.cc:86
Mysql_Clone_Key_Values
std::vector< std::pair< std::string, std::string > > Mysql_Clone_Key_Values
Vector of string Key-Value pairs.
Definition: clone_protocol_service.h:71
sql_thd_internal_api.h
mysql_clone_connect
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:243
port
static in_port_t port
Definition: testapp.c:33
mysql_clone_ssl_context
Connection parameters including SSL.
Definition: clone_protocol_service.h:52
mysql_clone_send_response
int mysql_clone_send_response(THD *thd, bool secure, uchar *packet, size_t length) noexcept
Send response to client.
Definition: clone_protocol_service.cc:579
uchar
unsigned char uchar
Definition: my_inttypes.h:51
mysql_clone_validate_charsets
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:121
mysql_clone_get_charsets
int mysql_clone_get_charsets(THD *thd, Mysql_Clone_Values &char_sets) noexcept
Get all character set and collations.
Definition: clone_protocol_service.cc:99
component_implementation.h
command
command
Definition: version_token.cc:278
user
char * user
Definition: mysqladmin.cc:59
PSI_statement_key
unsigned int PSI_statement_key
Instrumented statement key.
Definition: psi_statement_bits.h:45
Mysql_Clone_Values
std::vector< std::string > Mysql_Clone_Values
Vector of sting Values.
Definition: clone_protocol_service.h:68
mysql_clone_get_configs
int mysql_clone_get_configs(THD *thd, Mysql_Clone_Key_Values &configs) noexcept
Get system configuration parameter values.
Definition: clone_protocol_service.cc:180
mysql_clone_get_response
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:399
undo::set_active
void set_active(space_id_t space_id)
Set an undo tablespace active.
Definition: trx0purge.cc:1072
MYSQL
Definition: mysql.h:295
PSI_thread_key
unsigned int PSI_thread_key
Instrumented thread key.
Definition: psi_thread_bits.h:48
gis::length
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:75
DEFINE_METHOD
#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:78
mysql_clone_send_error
int mysql_clone_send_error(THD *thd, uchar err_cmd, bool is_fatal) noexcept
Send error to client.
Definition: clone_protocol_service.cc:607
mysql_clone_disconnect
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:490
mysql_clone_kill
int mysql_clone_kill(MYSQL *connection, MYSQL *kill_connection) noexcept
Kill a remote connection.
Definition: clone_protocol_service.cc:475
MYSQL_SOCKET
An instrumented socket.
Definition: mysql_socket_bits.h:34