123 ulong execute_flags,
PS_PARAM *parameters);
133 ulong setup_tables_done_option);
177 const std::nothrow_t & = std::nothrow)
noexcept {
181 static void operator delete(
void *, size_t)
noexcept {
185 static void operator delete(
186 void *,
MEM_ROOT *,
const std::nothrow_t &)
noexcept {
327 assert(column_index <
size());
436 bool prepare(
THD *thd,
const char *packet,
size_t packet_length,
440#ifdef HAVE_PSI_PS_INTERFACE
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
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