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