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