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