127 ulong execute_flags,
PS_PARAM *parameters);
137 ulong setup_tables_done_option);
242 bool prepare(
THD *thd,
const char *packet,
size_t packet_length,
246#ifdef HAVE_PSI_PS_INTERFACE
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:936
Definition: sql_list.h:467
Prepared_statement: a statement that can contain placeholders.
Definition: sql_prepare.h:152
bool set_db(const LEX_CSTRING &db_length)
Remember the current database.
Definition: sql_prepare.cc:2281
bool execute_loop(THD *thd, String *expanded_query, bool open_cursor)
Execute a prepared statement.
Definition: sql_prepare.cc:2856
Prepared_statement(THD *thd_arg)
Definition: sql_prepare.cc:2164
const Protocol * m_active_protocol
Used to check that the protocol is stable during execution.
Definition: sql_prepare.h:164
bool insert_parameters(THD *thd, String *query, bool has_new_types, PS_PARAM *parameters, enum enum_param_pack_type param_pack_type)
Assign parameter values from data supplied by the client.
Definition: sql_prepare.cc:642
LEX_CSTRING m_query_string
The query string associated with this statement.
Definition: sql_prepare.h:181
bool prepare_query(THD *thd)
Perform semantic analysis of query and send a response packet to client.
Definition: sql_prepare.cc:1193
LEX_CSTRING m_db
Name of the current (default) database.
Definition: sql_prepare.h:221
bool execute(THD *thd, String *expanded_query, bool open_cursor)
Execute a prepared statement that has already been prepared.
Definition: sql_prepare.cc:3259
ulong id() const
Definition: sql_prepare.h:237
Server_side_cursor * m_cursor
Pointer to cursor, may be NULL if statement never used with a cursor.
Definition: sql_prepare.h:161
bool validate_metadata(THD *thd, Prepared_statement *copy)
Validate statement result set metadata (if the statement returns a result set).
Definition: sql_prepare.cc:3168
bool check_parameter_types()
Check resolved parameter types versus actual parameter types.
Definition: sql_prepare.cc:2648
void trace_parameter_types(THD *thd)
Definition: sql_prepare.cc:1407
void swap_prepared_statement(Prepared_statement *copy)
Swap the MEM_ROOT allocated data of two prepared statements.
Definition: sql_prepare.cc:3199
const LEX_CSTRING & name() const
Definition: sql_prepare.h:236
virtual ~Prepared_statement()
Destroy this prepared statement, cleaning up all used memory and resources.
Definition: sql_prepare.cc:2230
enum_param_pack_type
Definition: sql_prepare.h:267
@ PACKED
Definition: sql_prepare.h:271
@ UNPACKED
Definition: sql_prepare.h:279
bool m_used_as_cursor
True if statement is used with cursor, false if used in regular execution.
Definition: sql_prepare.h:188
Item_param ** m_param_array
Array of parameters used for statement, may be NULL if there are none.
Definition: sql_prepare.h:158
void deallocate(THD *thd)
Common part of DEALLOCATE PREPARE and mysqld_stmt_close.
Definition: sql_prepare.cc:3569
bool m_in_use
Flag that prevents recursive invocation of prepared statements.
Definition: sql_prepare.h:203
void setup_stmt_logging(THD *thd)
Definition: sql_prepare.cc:2178
bool is_sql_prepare() const
Definition: sql_prepare.h:239
Query_arena m_arena
Memory allocation arena, for permanent allocations to statement.
Definition: sql_prepare.h:155
void set_sql_prepare(bool prepare=true)
Definition: sql_prepare.h:240
bool execute_server_runnable(THD *thd, Server_runnable *server_runnable)
Definition: sql_prepare.cc:3020
LEX_CSTRING m_name
Name of the prepared statement.
Definition: sql_prepare.h:208
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:227
bool reprepare(THD *thd)
Reprepare this prepared statement.
Definition: sql_prepare.cc:3078
Query_result * m_regular_result
Query result used when statement is used in regular execution.
Definition: sql_prepare.h:191
LEX * m_lex
Definition: sql_prepare.h:178
bool m_with_log
Definition: sql_prepare.h:205
bool insert_parameters_from_vars(THD *thd, List< LEX_STRING > &varnames, String *query)
Assign prepared statement parameters from user variables.
Definition: sql_prepare.cc:863
void cleanup_stmt(THD *thd)
Definition: sql_prepare.cc:2256
void close_cursor()
Definition: sql_prepare.cc:2172
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:2325
Query_result * m_cursor_result
Query result used when statement is used with a cursor.
Definition: sql_prepare.h:194
uint m_param_count
Number of parameters expected for statement.
Definition: sql_prepare.h:167
Query_result * m_aux_result
Auxiliary query result object, saved for proper destruction.
Definition: sql_prepare.h:197
const ulong m_id
Uniquely identifies each statement object in thread scope; change during statement lifetime.
Definition: sql_prepare.h:176
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:2582
bool m_is_sql_prepare
Flag that specifies preparation state.
Definition: sql_prepare.h:200
bool set_name(const LEX_CSTRING &name)
Definition: sql_prepare.cc:2264
void copy_parameter_types(Item_param **from_param_array)
Copy parameter metada data from parameter array into current prepared stmt.
Definition: sql_prepare.cc:793
char m_last_error[MYSQL_ERRMSG_SIZE]
Definition: sql_prepare.h:170
PSI_prepared_stmt * get_PS_prepared_stmt()
Definition: sql_prepare.h:247
uint m_last_errno
Definition: sql_prepare.h:169
bool is_in_use() const
Definition: sql_prepare.h:238
PSI_prepared_stmt * m_prepared_stmt
Performance Schema interface for a prepared statement.
Definition: sql_prepare.h:184
Definition: protocol.h:33
Definition: sql_class.h:348
Definition: query_result.h:191
Definition: query_result.h:58
An interface that is used to take an action when the locking module notices that a table version has ...
Definition: sql_prepare.h:82
bool is_invalidated() const
Definition: sql_prepare.h:95
bool report_error(THD *thd)
Check if a change of metadata is OK.
Definition: sql_prepare.cc:2126
bool can_retry() const
Definition: sql_prepare.h:98
void reset_reprepare_observer()
Definition: sql_prepare.h:96
bool m_invalidated
Definition: sql_prepare.h:107
int m_attempt
Definition: sql_prepare.h:108
static constexpr int MAX_REPREPARE_ATTEMPTS
Definition: sql_prepare.h:114
Execute a fragment of server code in an isolated context, so that it doesn't leave any effect on THD.
Definition: statement_runnable.h:42
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:167
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
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:47
Common definition between mysql server & client.
#define MYSQL_ERRMSG_SIZE
Max length of a error message.
Definition: mysql_com.h:881
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:1485
void mysql_sql_stmt_close(THD *thd)
SQLCOM_DEALLOCATE implementation.
Definition: sql_prepare.cc:2006
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:1917
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:2047
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:1534
void mysqld_stmt_close(THD *thd, Prepared_statement *stmt)
Delete a prepared statement from memory.
Definition: sql_prepare.cc:1983
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:2151
void reset_stmt_parameters(Prepared_statement *stmt)
Clears parameters from data left from previous execution or long data.
Definition: sql_prepare.cc:1790
void mysql_sql_stmt_execute(THD *thd)
SQLCOM_EXECUTE implementation.
Definition: sql_prepare.cc:1881
void log_execute_line(THD *thd)
Unless we're doing dynamic SQL, write the current query to the general query log if it's open.
Definition: sql_prepare.cc:251
void rewrite_query(THD *thd)
Rewrite the current query (to obfuscate passwords etc.).
Definition: sql_prepare.cc:228
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:1818
void mysqld_stmt_reset(THD *thd, Prepared_statement *stmt)
Reset a prepared statement in case there was a recoverable error.
Definition: sql_prepare.cc:1956
void mysql_sql_stmt_prepare(THD *thd)
SQLCOM_PREPARE implementation.
Definition: sql_prepare.cc:1723
The LEX object currently serves three different purposes:
Definition: sql_lex.h:3823
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:83
Definition: mysql_lex_string.h:40
Definition: com_data.h:46
Definition: com_data.h:104