MySQL 8.3.0
Source Code Documentation
sql_prepare.h
Go to the documentation of this file.
1#ifndef SQL_PREPARE_H
2#define SQL_PREPARE_H
3/* Copyright (c) 2009, 2023, Oracle and/or its affiliates.
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License, version 2.0,
7 as published by the Free Software Foundation.
8
9 This program is also distributed with certain software (including
10 but not limited to OpenSSL) that is licensed under separate terms,
11 as designated in a particular file or component or in included license
12 documentation. The authors of MySQL hereby grant you an additional
13 permission to link the program and your derivative works with the
14 separately licensed software that they have included with MySQL.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License, version 2.0, for more details.
20
21 You should have received a copy of the GNU General Public License
22 along with this program; if not, write to the Free Software
23 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
24
25#include <assert.h>
26#include <stddef.h>
27#include <sys/types.h>
28#include <new>
29
30#include "lex_string.h"
31#include "my_alloc.h"
32#include "my_command.h"
33
34#include "my_inttypes.h"
35#include "my_psi_config.h"
37#include "mysql_com.h"
38#include "sql/sql_class.h" // Query_arena
39#include "sql/sql_error.h"
40#include "sql/sql_list.h"
41
42class Item;
43class Item_param;
46class String;
47struct LEX;
48struct PS_PARAM;
49class Table_ref;
50union COM_DATA;
51
52/**
53 An interface that is used to take an action when
54 the locking module notices that a table version has changed
55 since the last execution. "Table" here may refer to any kind of
56 table -- a base table, a temporary table, a view or an
57 information schema table.
58
59 When we open and lock tables for execution of a prepared
60 statement, we must verify that they did not change
61 since statement prepare. If some table did change, the statement
62 parse tree *may* be no longer valid, e.g. in case it contains
63 optimizations that depend on table metadata.
64
65 This class provides an interface (a method) that is
66 invoked when such a situation takes place.
67 The implementation of the method simply reports an error, but
68 the exact details depend on the nature of the SQL statement.
69
70 At most 1 instance of this class is active at a time, in which
71 case THD::m_reprepare_observer is not NULL.
72
73 @sa check_and_update_table_version() for details of the
74 version tracking algorithm
75
76 @sa Open_tables_state::m_reprepare_observer for the life cycle
77 of metadata observers.
78*/
79
80class Reprepare_observer final {
81 public:
82 /**
83 Check if a change of metadata is OK. In future
84 the signature of this method may be extended to accept the old
85 and the new versions, but since currently the check is very
86 simple, we only need the THD to report an error.
87 */
88 bool report_error(THD *thd);
89 /**
90 @returns true if some table metadata is changed and statement should be
91 re-prepared.
92 */
93 bool is_invalidated() const { return m_invalidated; }
95 /// @returns true if prepared statement can (and will) be retried
96 bool can_retry() const {
97 // Only call for a statement that is invalidated
98 assert(is_invalidated());
100 DBUG_EVALUATE_IF("simulate_max_reprepare_attempts_hit_case", false,
101 true);
102 }
103
104 private:
105 bool m_invalidated{false};
106 int m_attempt{0};
107
108 /*
109 We take only 3 attempts to reprepare the query, otherwise we might end up
110 in endless loop.
111 */
112 static constexpr int MAX_REPREPARE_ATTEMPTS = 3;
113};
114
115bool ask_to_reprepare(THD *thd);
116bool mysql_stmt_precheck(THD *thd, const COM_DATA *com_data,
117 enum enum_server_command cmd,
118 Prepared_statement **stmt);
119void mysqld_stmt_prepare(THD *thd, const char *query, uint length,
120 Prepared_statement *stmt);
121void mysqld_stmt_execute(THD *thd, Prepared_statement *stmt, bool has_new_types,
122 ulong execute_flags, PS_PARAM *parameters);
124void mysql_sql_stmt_prepare(THD *thd);
125void mysql_sql_stmt_execute(THD *thd);
126void mysql_sql_stmt_close(THD *thd);
127void mysqld_stmt_fetch(THD *thd, Prepared_statement *stmt, ulong num_rows);
130 uint param_number, uchar *longdata, ulong length);
132 ulong setup_tables_done_option);
133
134/**
135 Execute a fragment of server code in an isolated context, so that
136 it doesn't leave any effect on THD. THD must have no open tables.
137 The code must not leave any open tables around.
138 The result of execution (if any) is stored in Ed_result.
139*/
140
142 public:
143 virtual bool execute_server_code(THD *thd) = 0;
145};
146
147/**
148 Execute direct interface.
149
150 @todo Implement support for prelocked mode.
151*/
152
153class Ed_row;
154
155/**
156 Ed_result_set -- a container with result set rows.
157 @todo Implement support for result set metadata and
158 automatic type conversion.
159*/
160
161class Ed_result_set final {
162 public:
163 operator List<Ed_row> &() { return *m_rows; }
164 unsigned int size() const { return m_rows->elements; }
166
167 Ed_result_set(List<Ed_row> *rows_arg, Ed_row *fields, size_t column_count,
168 MEM_ROOT *mem_root_arg);
169
170 /** We don't call member destructors, they all are POD types. */
171 ~Ed_result_set() = default;
172
173 size_t get_field_count() const { return m_column_count; }
174
175 static void *operator new(size_t size, MEM_ROOT *mem_root,
176 const std::nothrow_t & = std::nothrow) noexcept {
177 return mem_root->Alloc(size);
178 }
179
180 static void operator delete(void *, size_t) noexcept {
181 // Does nothing because m_mem_root is deallocated in the destructor
182 }
183
184 static void operator delete(
185 void *, MEM_ROOT *, const std::nothrow_t &) noexcept { /* never called */
186 }
187
188 private:
189 Ed_result_set(const Ed_result_set &); /* not implemented */
190 Ed_result_set &operator=(Ed_result_set &); /* not implemented */
191 private:
197 friend class Ed_connection;
198};
199
200class Ed_connection final {
201 public:
202 /**
203 Construct a new "execute direct" connection.
204
205 The connection can be used to execute SQL statements.
206 If the connection failed to initialize, the error
207 will be returned on the attempt to execute a statement.
208
209 @pre thd must have no open tables
210 while the connection is used. However,
211 Ed_connection works okay in LOCK TABLES mode.
212 Other properties of THD, such as the current warning
213 information, errors, etc. do not matter and are
214 preserved by Ed_connection. One thread may have many
215 Ed_connections created for it.
216 */
217 Ed_connection(THD *thd);
218
219 /**
220 Execute one SQL statement.
221
222 Until this method is executed, no other methods of
223 Ed_connection can be used. Life cycle of Ed_connection is:
224
225 Initialized -> a statement has been executed ->
226 look at result, move to next result ->
227 look at result, move to next result ->
228 ...
229 moved beyond the last result == Initialized.
230
231 This method can be called repeatedly. Once it's invoked,
232 results of the previous execution are lost.
233
234 A result of execute_direct() can be either:
235
236 - success, no result set rows. In this case get_field_count()
237 returns 0. This happens after execution of INSERT, UPDATE,
238 DELETE, DROP and similar statements. Some other methods, such
239 as get_affected_rows() can be used to retrieve additional
240 result information.
241
242 - success, there are some result set rows (maybe 0). E.g.
243 happens after SELECT. In this case get_field_count() returns
244 the number of columns in a result set and store_result()
245 can be used to retrieve a result set..
246
247 - an error, methods to retrieve error information can
248 be used.
249
250 @return execution status
251 @retval false success, use get_field_count()
252 to determine what to do next.
253 @retval true error, use get_last_error()
254 to see the error number.
255 */
256 bool execute_direct(LEX_STRING sql_text);
257
258 /**
259 Same as the previous, but takes an instance of Server_runnable
260 instead of SQL statement text.
261
262 @return execution status
263
264 @retval false success, use get_field_count()
265 if your code fragment is supposed to
266 return a result set
267 @retval true failure
268 */
269 bool execute_direct(Server_runnable *server_runnable);
270
271 /**
272 The following three members are only valid if execute_direct()
273 or move_to_next_result() returned an error.
274 They never fail, but if they are called when there is no
275 result, or no error, the result is not defined.
276 */
277 const char *get_last_error() const {
279 }
280
281 unsigned int get_last_errno() const {
283 }
284
286
288
289 private:
291 /**
292 Execute direct interface does not support multi-statements, only
293 multi-results. So we never have a situation when we have
294 a mix of result sets and OK or error packets. We either
295 have a single result set, a single error, or a single OK,
296 or we have a series of result sets, followed by an OK or error.
297 */
301 friend class Protocol_local;
302
303 private:
304 void free_old_result();
305 void add_result_set(Ed_result_set *ed_result_set);
306
307 private:
308 Ed_connection(const Ed_connection &); /* not implemented */
309 Ed_connection &operator=(Ed_connection &); /* not implemented */
310};
311
312/** One result set column. */
313
314struct Ed_column final : public LEX_STRING {
315 /** Implementation note: destructor for this class is never called. */
316};
317
318/** One result set record. */
319
320class Ed_row final {
321 public:
322 const Ed_column &operator[](const unsigned int column_index) const {
323 return *get_column(column_index);
324 }
325 const Ed_column *get_column(const unsigned int column_index) const {
326 assert(column_index < size());
327 return m_column_array + column_index;
328 }
329 size_t size() const { return m_column_count; }
330
331 Ed_row(Ed_column *column_array_arg, size_t column_count_arg)
332 : m_column_array(column_array_arg), m_column_count(column_count_arg) {}
333
334 private:
336 size_t m_column_count; /* TODO: change to point to metadata */
337};
338
340
341/**
342 Prepared_statement: a statement that can contain placeholders.
343*/
344
346 public:
347 /// Memory allocation arena, for permanent allocations to statement.
349
350 /// Array of parameters used for statement, may be NULL if there are none.
352
353 /// Pointer to cursor, may be NULL if statement never used with a cursor.
355
356 /// Used to check that the protocol is stable during execution
358
359 /// Number of parameters expected for statement
361
364
365 /**
366 Uniquely identifies each statement object in thread scope; change during
367 statement lifetime.
368 */
369 const ulong m_id;
370
371 LEX *m_lex{nullptr}; // parse tree descriptor
372
373 /// The query string associated with this statement.
375
376 /// Performance Schema interface for a prepared statement.
378
379 private:
380 /// True if statement is used with cursor, false if used in regular execution
381 bool m_used_as_cursor{false};
382
383 /// Query result used when statement is used in regular execution.
385
386 /// Query result used when statement is used with a cursor.
388
389 /// Auxiliary query result object, saved for proper destruction
391
392 /// Flag that specifies preparation state
393 bool m_is_sql_prepare{false};
394
395 /// Flag that prevents recursive invocation of prepared statements
396 bool m_in_use{false};
397
398 bool m_with_log{false};
399
400 /// Name of the prepared statement.
402 /**
403 Name of the current (default) database.
404
405 If there is the current (default) database, "db" contains its name. If
406 there is no current (default) database, "db" is NULL and "db_length" is
407 0. In other words, "db", "db_length" must either be NULL, or contain a
408 valid database name.
409
410 @note this attribute is set and allocated by the slave SQL thread (for
411 the THD of that thread); that thread is (and must remain, for now) the
412 only responsible for freeing this member.
413 */
415
416 /**
417 The memory root to allocate parsed tree elements (instances of Item,
418 Query_block and other classes).
419 */
421
422 bool prepare_query(THD *thd);
423
424 public:
425 Prepared_statement(THD *thd_arg);
426 virtual ~Prepared_statement();
427
428 bool set_name(const LEX_CSTRING &name);
429 const LEX_CSTRING &name() const { return m_name; }
430 ulong id() const { return m_id; }
431 bool is_in_use() const { return m_in_use; }
432 bool is_sql_prepare() const { return m_is_sql_prepare; }
434 void deallocate(THD *thd);
435 bool prepare(THD *thd, const char *packet, size_t packet_length,
436 Item_param **orig_param_array);
437 bool execute_loop(THD *thd, String *expanded_query, bool open_cursor);
438 bool execute_server_runnable(THD *thd, Server_runnable *server_runnable);
439#ifdef HAVE_PSI_PS_INTERFACE
441#endif
442 bool set_parameters(THD *thd, String *expanded_query, bool has_new_types,
443 PS_PARAM *parameters);
444 bool set_parameters(THD *thd, String *expanded_query);
445 void trace_parameter_types(THD *thd);
446 void close_cursor();
447
448 private:
449 void cleanup_stmt(THD *thd);
450 void setup_stmt_logging(THD *thd);
452 void copy_parameter_types(Item_param **from_param_array);
453 bool set_db(const LEX_CSTRING &db_length);
454
455 bool execute(THD *thd, String *expanded_query, bool open_cursor);
456 bool reprepare(THD *thd);
460 String *query);
461 bool insert_parameters(THD *thd, String *query, bool has_new_types,
462 PS_PARAM *parameters);
463};
464
465#endif // SQL_PREPARE_H
Stores status of the currently executed statement.
Definition: sql_error.h:268
const char * message_text() const
Definition: sql_error.h:375
uint mysql_errno() const
Definition: sql_error.h:385
Definition: sql_prepare.h:200
Diagnostics_area m_diagnostics_area
Definition: sql_prepare.h:290
Ed_connection(THD *thd)
Construct a new "execute direct" connection.
Definition: sql_prepare.cc:3732
Ed_result_set * m_rsets
Definition: sql_prepare.h:299
unsigned int get_last_errno() const
Definition: sql_prepare.h:281
~Ed_connection()
Definition: sql_prepare.h:287
bool execute_direct(LEX_STRING sql_text)
Execute one SQL statement.
Definition: sql_prepare.cc:3760
Ed_result_set * m_current_rset
Definition: sql_prepare.h:300
Ed_connection & operator=(Ed_connection &)
Ed_connection(const Ed_connection &)
const char * get_last_error() const
The following three members are only valid if execute_direct() or move_to_next_result() returned an e...
Definition: sql_prepare.h:277
void free_old_result()
Free all result sets of the previous statement, if any, and reset warnings and errors.
Definition: sql_prepare.cc:3745
Ed_result_set * get_result_sets()
Definition: sql_prepare.h:285
THD * m_thd
Execute direct interface does not support multi-statements, only multi-results.
Definition: sql_prepare.h:298
void add_result_set(Ed_result_set *ed_result_set)
A helper method that is called only during execution.
Definition: sql_prepare.cc:3823
Ed_result_set – a container with result set rows.
Definition: sql_prepare.h:161
Ed_result_set(const Ed_result_set &)
MEM_ROOT m_mem_root
Definition: sql_prepare.h:192
Ed_result_set & operator=(Ed_result_set &)
Ed_row * m_fields
Definition: sql_prepare.h:195
Ed_result_set(List< Ed_row > *rows_arg, Ed_row *fields, size_t column_count, MEM_ROOT *mem_root_arg)
Initialize an instance of Ed_result_set.
Definition: sql_prepare.cc:3716
Ed_result_set * m_next_rset
Definition: sql_prepare.h:196
Ed_row * get_fields()
Definition: sql_prepare.h:165
size_t get_field_count() const
Definition: sql_prepare.h:173
List< Ed_row > * m_rows
Definition: sql_prepare.h:194
size_t m_column_count
Definition: sql_prepare.h:193
unsigned int size() const
Definition: sql_prepare.h:164
~Ed_result_set()=default
We don't call member destructors, they all are POD types.
One result set record.
Definition: sql_prepare.h:320
const Ed_column * get_column(const unsigned int column_index) const
Definition: sql_prepare.h:325
Ed_row(Ed_column *column_array_arg, size_t column_count_arg)
Definition: sql_prepare.h:331
size_t size() const
Definition: sql_prepare.h:329
size_t m_column_count
Definition: sql_prepare.h:336
const Ed_column & operator[](const unsigned int column_index) const
Definition: sql_prepare.h:322
Ed_column * m_column_array
Definition: sql_prepare.h:335
Dynamic parameters used as placeholders ('?') inside prepared statements.
Definition: item.h:4757
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:933
Definition: sql_list.h:434
Prepared_statement: a statement that can contain placeholders.
Definition: sql_prepare.h:345
bool set_db(const LEX_CSTRING &db_length)
Remember the current database.
Definition: sql_prepare.cc:2422
bool execute_loop(THD *thd, String *expanded_query, bool open_cursor)
Execute a prepared statement.
Definition: sql_prepare.cc:2998
Prepared_statement(THD *thd_arg)
Definition: sql_prepare.cc:2305
const Protocol * m_active_protocol
Used to check that the protocol is stable during execution.
Definition: sql_prepare.h:357
LEX_CSTRING m_query_string
The query string associated with this statement.
Definition: sql_prepare.h:374
bool prepare_query(THD *thd)
Perform semantic analysis of query and send a response packet to client.
Definition: sql_prepare.cc:1264
LEX_CSTRING m_db
Name of the current (default) database.
Definition: sql_prepare.h:414
bool execute(THD *thd, String *expanded_query, bool open_cursor)
Execute a prepared statement that has already been prepared.
Definition: sql_prepare.cc:3397
ulong id() const
Definition: sql_prepare.h:430
Server_side_cursor * m_cursor
Pointer to cursor, may be NULL if statement never used with a cursor.
Definition: sql_prepare.h:354
bool validate_metadata(THD *thd, Prepared_statement *copy)
Validate statement result set metadata (if the statement returns a result set).
Definition: sql_prepare.cc:3306
bool check_parameter_types()
Check resolved parameter types versus actual parameter types.
Definition: sql_prepare.cc:2790
void trace_parameter_types(THD *thd)
Definition: sql_prepare.cc:1478
void swap_prepared_statement(Prepared_statement *copy)
Swap the MEM_ROOT allocated data of two prepared statements.
Definition: sql_prepare.cc:3337
const LEX_CSTRING & name() const
Definition: sql_prepare.h:429
virtual ~Prepared_statement()
Destroy this prepared statement, cleaning up all used memory and resources.
Definition: sql_prepare.cc:2371
bool m_used_as_cursor
True if statement is used with cursor, false if used in regular execution.
Definition: sql_prepare.h:381
Item_param ** m_param_array
Array of parameters used for statement, may be NULL if there are none.
Definition: sql_prepare.h:351
void deallocate(THD *thd)
Common part of DEALLOCATE PREPARE and mysqld_stmt_close.
Definition: sql_prepare.cc:3694
bool m_in_use
Flag that prevents recursive invocation of prepared statements.
Definition: sql_prepare.h:396
void setup_stmt_logging(THD *thd)
Definition: sql_prepare.cc:2319
bool is_sql_prepare() const
Definition: sql_prepare.h:432
Query_arena m_arena
Memory allocation arena, for permanent allocations to statement.
Definition: sql_prepare.h:348
void set_sql_prepare(bool prepare=true)
Definition: sql_prepare.h:433
bool execute_server_runnable(THD *thd, Server_runnable *server_runnable)
Definition: sql_prepare.cc:3158
LEX_CSTRING m_name
Name of the prepared statement.
Definition: sql_prepare.h:401
MEM_ROOT m_mem_root
The memory root to allocate parsed tree elements (instances of Item, Query_block and other classes).
Definition: sql_prepare.h:420
bool reprepare(THD *thd)
Reprepare this prepared statement.
Definition: sql_prepare.cc:3216
Query_result * m_regular_result
Query result used when statement is used in regular execution.
Definition: sql_prepare.h:384
LEX * m_lex
Definition: sql_prepare.h:371
bool m_with_log
Definition: sql_prepare.h:398
bool insert_parameters_from_vars(THD *thd, List< LEX_STRING > &varnames, String *query)
Assign prepared statement parameters from user variables.
Definition: sql_prepare.cc:932
void cleanup_stmt(THD *thd)
Definition: sql_prepare.cc:2397
void close_cursor()
Definition: sql_prepare.cc:2313
bool prepare(THD *thd, const char *packet, size_t packet_length, Item_param **orig_param_array)
Parse statement text, validate the statement, and prepare it for execution.
Definition: sql_prepare.cc:2466
Query_result * m_cursor_result
Query result used when statement is used with a cursor.
Definition: sql_prepare.h:387
uint m_param_count
Number of parameters expected for statement.
Definition: sql_prepare.h:360
Query_result * m_aux_result
Auxiliary query result object, saved for proper destruction.
Definition: sql_prepare.h:390
const ulong m_id
Uniquely identifies each statement object in thread scope; change during statement lifetime.
Definition: sql_prepare.h:369
bool set_parameters(THD *thd, String *expanded_query, bool has_new_types, PS_PARAM *parameters)
Assign parameter values from the execute packet.
Definition: sql_prepare.cc:2733
bool m_is_sql_prepare
Flag that specifies preparation state.
Definition: sql_prepare.h:393
bool set_name(const LEX_CSTRING &name)
Definition: sql_prepare.cc:2405
bool insert_parameters(THD *thd, String *query, bool has_new_types, PS_PARAM *parameters)
Assign parameter values from data supplied by the client.
Definition: sql_prepare.cc:741
void copy_parameter_types(Item_param **from_param_array)
Copy parameter metada data from parameter array into current prepared stmt.
Definition: sql_prepare.cc:862
char m_last_error[MYSQL_ERRMSG_SIZE]
Definition: sql_prepare.h:363
PSI_prepared_stmt * get_PS_prepared_stmt()
Definition: sql_prepare.h:440
uint m_last_errno
Definition: sql_prepare.h:362
bool is_in_use() const
Definition: sql_prepare.h:431
PSI_prepared_stmt * m_prepared_stmt
Performance Schema interface for a prepared statement.
Definition: sql_prepare.h:377
Protocol_local: a helper class to intercept the result of the data written to the network.
Definition: sql_prepare.cc:249
Definition: protocol.h:32
Definition: sql_class.h:347
Definition: query_result.h:190
Definition: query_result.h:57
An interface that is used to take an action when the locking module notices that a table version has ...
Definition: sql_prepare.h:80
bool is_invalidated() const
Definition: sql_prepare.h:93
bool report_error(THD *thd)
Check if a change of metadata is OK.
Definition: sql_prepare.cc:2197
bool can_retry() const
Definition: sql_prepare.h:96
void reset_reprepare_observer()
Definition: sql_prepare.h:94
bool m_invalidated
Definition: sql_prepare.h:105
int m_attempt
Definition: sql_prepare.h:106
static constexpr int MAX_REPREPARE_ATTEMPTS
Definition: sql_prepare.h:112
Execute a fragment of server code in an isolated context, so that it doesn't leave any effect on THD.
Definition: sql_prepare.h:141
virtual bool execute_server_code(THD *thd)=0
virtual ~Server_runnable()
Server_side_cursor – an interface for materialized implementation of cursors.
Definition: sql_cursor.h:50
Definition: sql_cmd_dml.h:34
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:166
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:35
Definition: table.h:2853
static MEM_ROOT mem_root
Definition: client_plugin.cc:113
struct PSI_prepared_stmt PSI_prepared_stmt
Definition: psi_statement_bits.h:104
constexpr const LEX_CSTRING NULL_CSTR
Definition: lex_string.h:46
This file follows Google coding style, except for the name MEM_ROOT (which is kept for historical rea...
enum_server_command
A list of all MySQL protocol commands.
Definition: my_command.h:47
#define DBUG_EVALUATE_IF(keyword, a1, a2)
Definition: my_dbug.h:178
Some integer typedefs for easier portability.
unsigned char uchar
Definition: my_inttypes.h:51
Defines various enable/disable and HAVE_ macros related to the performance schema instrumentation sys...
static char * query
Definition: myisam_ftdump.cc:46
Common definition between mysql server & client.
#define MYSQL_ERRMSG_SIZE
Max length of a error message.
Definition: mysql_com.h:886
void copy(Shards< COUNT > &dst, const Shards< COUNT > &src) noexcept
Copy the counters, overwrite destination.
Definition: ut0counter.h:353
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
Performance schema instrumentation interface.
void mysqld_stmt_prepare(THD *thd, const char *query, uint length, Prepared_statement *stmt)
COM_STMT_PREPARE handler.
Definition: sql_prepare.cc:1556
void mysql_sql_stmt_close(THD *thd)
SQLCOM_DEALLOCATE implementation.
Definition: sql_prepare.cc:2077
void mysqld_stmt_fetch(THD *thd, Prepared_statement *stmt, ulong num_rows)
COM_STMT_FETCH handler: fetches requested amount of rows from cursor.
Definition: sql_prepare.cc:1988
void mysql_stmt_get_longdata(THD *thd, Prepared_statement *stmt, uint param_number, uchar *longdata, ulong length)
Handle long data in pieces from client.
Definition: sql_prepare.cc:2118
bool mysql_stmt_precheck(THD *thd, const COM_DATA *com_data, enum enum_server_command cmd, Prepared_statement **stmt)
Searches for the statement with the specified id and validates it.
Definition: sql_prepare.cc:1605
void mysqld_stmt_close(THD *thd, Prepared_statement *stmt)
Delete a prepared statement from memory.
Definition: sql_prepare.cc:2054
bool select_like_stmt_cmd_test(THD *thd, class Sql_cmd_dml *cmd, ulong setup_tables_done_option)
bool ask_to_reprepare(THD *thd)
Requests for repreparation of statement.
Definition: sql_prepare.cc:2222
void mysql_sql_stmt_execute(THD *thd)
SQLCOM_EXECUTE implementation.
Definition: sql_prepare.cc:1952
void mysqld_stmt_execute(THD *thd, Prepared_statement *stmt, bool has_new_types, ulong execute_flags, PS_PARAM *parameters)
COM_STMT_EXECUTE handler: execute a previously prepared statement.
Definition: sql_prepare.cc:1889
void mysqld_stmt_reset(THD *thd, Prepared_statement *stmt)
Reset a prepared statement in case there was a recoverable error.
Definition: sql_prepare.cc:2027
void mysql_sql_stmt_prepare(THD *thd)
SQLCOM_PREPARE implementation.
Definition: sql_prepare.cc:1794
One result set column.
Definition: sql_prepare.h:314
The LEX object currently serves three different purposes:
Definition: sql_lex.h:3787
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:82
void * Alloc(size_t length)
Allocate memory.
Definition: my_alloc.h:144
Definition: mysql_lex_string.h:39
Definition: mysql_lex_string.h:34
Definition: com_data.h:45
Definition: com_data.h:96