MySQL 8.0.40
Source Code Documentation
sql_service_context.h
Go to the documentation of this file.
1/* Copyright (c) 2015, 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#ifndef SQL_SERVICE_CONTEXT_INCLUDE
25#define SQL_SERVICE_CONTEXT_INCLUDE
26
27#include <stddef.h>
28
29#include "my_inttypes.h"
31
33 public:
35 if (rset != nullptr) resultset->clear();
36 }
37
38 ~Sql_service_context() override = default;
39
40 /** Getting metadata **/
41 /**
42 Indicates start of metadata for the result set
43
44 @param num_cols Number of fields being sent
45 @param flags Flags to alter the metadata sending
46 @param resultcs Charset of the result set
47
48 @retval 1 Error
49 @retval 0 OK
50 */
52 const CHARSET_INFO *resultcs) override;
53
54 /**
55 Field metadata is provided via this callback
56
57 @param field Field's metadata (see field.h)
58 @param charset Field's charset
59
60 @retval 1 Error
61 @retval 0 OK
62 */
63 int field_metadata(struct st_send_field *field,
64 const CHARSET_INFO *charset) override;
65
66 /**
67 Indicates end of metadata for the result set
68
69 @param server_status Status of server (see mysql_com.h SERVER_STATUS_*)
70 @param warn_count Number of warnings thrown during execution
71
72 @retval 1 Error
73 @retval 0 OK
74 */
75 int end_result_metadata(uint server_status, uint warn_count) override;
76
77 /**
78 Indicates the beginning of a new row in the result set/metadata
79
80 @retval 1 Error
81 @retval 0 OK
82 */
83 int start_row() override;
84
85 /**
86 Indicates end of the row in the result set/metadata
87
88 @retval 1 Error
89 @retval 0 OK
90 */
91 int end_row() override;
92
93 /**
94 An error occurred during execution
95
96 @details This callback indicates that an error occurreded during command
97 execution and the partial row should be dropped. Server will raise error
98 and return.
99 */
100 void abort_row() override;
101
102 /**
103 Return client's capabilities (see mysql_com.h, CLIENT_*)
104
105 @return Bitmap of client's capabilities
106 */
107 ulong get_client_capabilities() override;
108
109 /** Getting data **/
110 /**
111 Receive NULL value from server
112
113 @return status
114 @retval 1 Error
115 @retval 0 OK
116 */
117 int get_null() override;
118
119 /**
120 Get TINY/SHORT/LONG value from server
121
122 @param value Value received
123
124 @note In order to know which type exactly was received, the plugin must
125 track the metadata that was sent just prior to the result set.
126
127 @return status
128 @retval 1 Error
129 @retval 0 OK
130 */
131 int get_integer(longlong value) override;
132
133 /**
134 Get LONGLONG value from server
135
136 @param value Value received
137 @param is_unsigned TRUE <=> value is unsigned
138
139 @return status
140 @retval 1 Error
141 @retval 0 OK
142 */
143 int get_longlong(longlong value, uint is_unsigned) override;
144
145 /**
146 Receive DECIMAL value from server
147
148 @param value Value received
149
150 @return status
151 @retval 1 Error
152 @retval 0 OK
153 */
154 int get_decimal(const decimal_t *value) override;
155
156 /**
157 Receive DOUBLE value from server
158
159 @return status
160 @retval 1 Error
161 @retval 0 OK
162 */
163 int get_double(double value, uint32 decimals) override;
164
165 /**
166 Get DATE value from server
167
168 @param value Value received
169
170 @return status
171 @retval 1 Error
172 @retval 0 OK
173 */
174 int get_date(const MYSQL_TIME *value) override;
175
176 /**
177 Get TIME value from server
178
179 @param value Value received
180 @param decimals Number of decimals
181
182 @return status
183 @retval 1 Error
184 @retval 0 OK
185 */
186 int get_time(const MYSQL_TIME *value, uint decimals) override;
187
188 /**
189 Get DATETIME value from server
190
191 @param value Value received
192 @param decimals Number of decimals
193
194 @return status
195 @retval 1 Error
196 @retval 0 OK
197 */
198 int get_datetime(const MYSQL_TIME *value, uint decimals) override;
199
200 /**
201 Get STRING value from server
202
203 @param value Value received
204 @param length Value's length
205 @param valuecs Value's charset
206
207 @return status
208 @retval 1 Error
209 @retval 0 OK
210 */
211 int get_string(const char *const value, size_t length,
212 const CHARSET_INFO *const valuecs) override;
213
214 /** Getting execution status **/
215 /**
216 Command ended with success
217
218 @param server_status Status of server (see mysql_com.h,
219 SERVER_STATUS_*)
220 @param statement_warn_count Number of warnings thrown during execution
221 @param affected_rows Number of rows affected by the command
222 @param last_insert_id Last insert id being assigned during execution
223 @param message A message from server
224 */
225 void handle_ok(uint server_status, uint statement_warn_count,
226 ulonglong affected_rows, ulonglong last_insert_id,
227 const char *const message) override;
228
229 /**
230 Command ended with ERROR
231
232 @param sql_errno Error code
233 @param err_msg Error message
234 @param sqlstate SQL state correspongin to the error code
235 */
236 void handle_error(uint sql_errno, const char *const err_msg,
237 const char *const sqlstate) override;
238
239 /**
240 Session was shutdown while command was running
241 */
242 void shutdown(int flag) override;
243
244 /**
245 Check if the connection is still alive.
246 */
247 bool connection_alive() override { return true; }
248
249 private:
250 /* executed command result store */
252};
253
254#endif // SQL_SERVICE_CONTEXT_INCLUDE
Definition: sql_resultset.h:72
void clear()
resultset class
Definition: sql_resultset.cc:104
Definition: sql_service_context_base.h:33
Definition: sql_service_context.h:32
Sql_service_context(Sql_resultset *rset)
Definition: sql_service_context.h:34
int get_datetime(const MYSQL_TIME *value, uint decimals) override
Get DATETIME value from server.
Definition: sql_service_context.cc:122
~Sql_service_context() override=default
int start_row() override
Indicates the beginning of a new row in the result set/metadata.
Definition: sql_service_context.cc:61
bool connection_alive() override
Check if the connection is still alive.
Definition: sql_service_context.h:247
void abort_row() override
An error occurred during execution.
Definition: sql_service_context.cc:73
void handle_ok(uint server_status, uint statement_warn_count, ulonglong affected_rows, ulonglong last_insert_id, const char *const message) override
Getting execution status.
Definition: sql_service_context.cc:136
int get_time(const MYSQL_TIME *value, uint decimals) override
Get TIME value from server.
Definition: sql_service_context.cc:116
void shutdown(int flag) override
Session was shutdown while command was running.
Definition: sql_service_context.cc:168
int start_result_metadata(uint num_cols, uint flags, const CHARSET_INFO *resultcs) override
Getting metadata.
Definition: sql_service_context.cc:28
int end_row() override
Indicates end of the row in the result set/metadata.
Definition: sql_service_context.cc:67
int field_metadata(struct st_send_field *field, const CHARSET_INFO *charset) override
Field metadata is provided via this callback.
Definition: sql_service_context.cc:39
int get_date(const MYSQL_TIME *value) override
Get DATE value from server.
Definition: sql_service_context.cc:110
int end_result_metadata(uint server_status, uint warn_count) override
Indicates end of metadata for the result set.
Definition: sql_service_context.cc:56
int get_longlong(longlong value, uint is_unsigned) override
Get LONGLONG value from server.
Definition: sql_service_context.cc:92
void handle_error(uint sql_errno, const char *const err_msg, const char *const sqlstate) override
Command ended with ERROR.
Definition: sql_service_context.cc:152
int get_decimal(const decimal_t *value) override
Receive DECIMAL value from server.
Definition: sql_service_context.cc:98
Sql_resultset * resultset
Definition: sql_service_context.h:251
ulong get_client_capabilities() override
Return client's capabilities (see mysql_com.h, CLIENT_*)
Definition: sql_service_context.cc:75
int get_null() override
Getting data.
Definition: sql_service_context.cc:80
int get_double(double value, uint32 decimals) override
Receive DOUBLE value from server.
Definition: sql_service_context.cc:104
int get_string(const char *const value, size_t length, const CHARSET_INFO *const valuecs) override
Get STRING value from server.
Definition: sql_service_context.cc:128
int get_integer(longlong value) override
Get TINY/SHORT/LONG value from server.
Definition: sql_service_context.cc:86
static int flags[50]
Definition: hp_test1.cc:40
static int flag
Definition: hp_test1.cc:40
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
long long int longlong
Definition: my_inttypes.h:55
uint32_t uint32
Definition: my_inttypes.h:67
constexpr value_type is_unsigned
Definition: classic_protocol_constants.h:273
const std::string charset("charset")
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
Definition: m_ctype.h:385
Definition: mysql_time.h:82
intg is the number of decimal digits (NOT number of decimal_digit_t's !) before the point frac is the...
Definition: decimal.h:52
Definition: service_command.h:45
unsigned int uint
Definition: uca9-dump.cc:75