28#include <forward_list>
57#define STMT_HANDLE_PSI_STATEMENT_INFO_COUNT 6
59#ifdef HAVE_PSI_INTERFACE
393#ifdef HAVE_PSI_INTERFACE
415 thd->variables.query_alloc_block_size) {}
446 unsigned long data_length,
const char *
name,
447 unsigned long name_length);
496 if (!
m_stmt)
return false;
558 return m_stmt !=
nullptr &&
568#ifdef HAVE_PSI_INTERFACE
591 template <
typename Function>
Stores status of the currently executed statement.
Definition: sql_error.h:269
bool is_error() const
Definition: sql_error.h:366
const char * message_text() const
Definition: sql_error.h:376
uint mysql_errno() const
Definition: sql_error.h:386
const char * returned_sqlstate() const
Definition: sql_error.h:391
Dynamic parameters used as placeholders ('?') inside prepared statements.
Definition: item.h:4789
Prepared_statement_handle enables support for prepared statement execution.
Definition: statement.h:410
Prepared_statement_handle(THD *thd, const char *query, uint length)
Definition: statement.h:412
bool reset()
Reset the statement parameters and cursors.
Definition: statement.cc:849
bool close()
Close the statement that is prepared.
Definition: statement.cc:854
bool m_bound_new_parameter_types
Definition: statement.h:662
ulong * m_parameter_buffer_max
Definition: statement.h:655
bool internal_close()
Definition: statement.cc:799
static PSI_statement_info fetch_psi_info
Definition: statement.h:572
bool is_executed_or_prepared() override
Check if the statement has been executed or prepared.
Definition: statement.h:557
static PSI_statement_info execute_psi_info
Definition: statement.h:571
bool execute() override
Execute the statement that is prepared.
Definition: statement.cc:839
bool run(Function exec_func, PSI_statement_info *psi_info)
This is a wrapper function used to execute and operation on Prepared_statement.
Definition: statement.cc:860
static PSI_statement_info prepare_psi_info
Definition: statement.h:570
bool internal_reset()
Definition: statement.cc:765
bool create_parameter_buffers()
Create a parameter buffers.
Definition: statement.cc:922
Prepared_statement * m_stmt
Definition: statement.h:637
bool prepare()
Prepares the statement using m_query.
Definition: statement.cc:834
uint get_param_count()
Get number of parameters used in the statement.
Definition: statement.h:542
bool is_cursor_open()
Check if the statement uses cursor and it is open.
Definition: statement.h:495
bool uses_cursor()
Check if the statement uses cursor.
Definition: statement.h:509
bool internal_fetch()
Definition: statement.cc:725
bool enable_cursor()
Method to enable cursor.
Definition: statement.cc:626
static PSI_statement_info close_psi_info
Definition: statement.h:574
bool fetch()
Fetch rows from statement using cursor.
Definition: statement.cc:844
bool internal_prepare()
Definition: statement.cc:552
virtual ~Prepared_statement_handle() override
Virtual destroy for Prepared_statement_handle object.
Definition: statement.h:566
bool set_parameter(uint idx, bool is_null, enum_field_types type, bool is_unsigned, const void *data, unsigned long data_length, const char *name, unsigned long name_length)
Set the parameter value in a prepared statement.
Definition: statement.cc:953
Item_param * get_parameter(size_t index)
Get the parameter object.
Definition: statement.cc:1005
MEM_ROOT m_parameter_mem_root
Definition: statement.h:648
static PSI_statement_info reset_psi_info
Definition: statement.h:573
bool internal_execute()
Definition: statement.cc:648
PS_PARAM * m_parameters
Definition: statement.h:640
bool is_prepared_statement() override
Convey that this is prepared statement.
Definition: statement.h:549
Prepared_statement: a statement that can contain placeholders.
Definition: sql_prepare.h:150
Server_side_cursor * m_cursor
Pointer to cursor, may be NULL if statement never used with a cursor.
Definition: sql_prepare.h:159
Query_arena m_arena
Memory allocation arena, for permanent allocations to statement.
Definition: sql_prepare.h:153
uint m_param_count
Number of parameters expected for statement.
Definition: sql_prepare.h:165
This is extention of Protocol_local.
Definition: protocol_local_v2.h:315
void set_result_set_capacity(size_t capacity)
Set the capacity in bytes allowed for caching results.
Definition: protocol_local_v2.h:432
size_t get_result_set_capacity()
Get the capacity in bytes allowed for caching results.
Definition: protocol_local_v2.h:439
Definition: protocol.h:33
enum_state get_state() const
Definition: sql_class.h:411
@ STMT_INITIALIZED
Definition: sql_class.h:368
@ STMT_EXECUTED
Definition: sql_class.h:372
Regular_statement_handle enables execution of all SQL statements except for prepared statements.
Definition: statement.h:360
bool is_prepared_statement() override
Convey that this is regular statement.
Definition: statement.h:382
static PSI_statement_info stmt_psi_info
Definition: statement.h:395
bool m_is_executed
Flag to indicate if statement has been executed. Set to true in execute().
Definition: statement.h:400
bool execute() override
Execute a regular statement.
Definition: statement.cc:295
Regular_statement_handle(THD *thd, const char *query, uint length)
Definition: statement.h:362
bool is_executed_or_prepared() override
Check if the statement has been executed.
Definition: statement.h:390
~Regular_statement_handle() override
Definition: statement.h:365
A result set contains the result of a query.
Definition: protocol_local_v2.h:154
Result_set * get_next()
Get the next result set object.
Definition: protocol_local_v2.h:284
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
virtual bool is_open() const =0
Statement_handle is similar to Ed_connection.
Definition: statement.h:81
size_t get_num_rows_per_fetch()
Get the num rows per fetch.
Definition: statement.h:274
void next_result_set()
Make the next result set the current result set.
Definition: statement.h:161
Statement_handle(Statement_handle &&)=delete
void set_capacity(size_t capacity)
Set the capacity in bytes allowed for caching results.
Definition: statement.h:209
Result_set * m_current_rset
Definition: statement.h:314
void set_num_rows_per_fetch(size_t num_rows_per_fetch)
Set the num of rows to be retrieved per fetch.
Definition: statement.h:281
Statement_handle & operator=(Statement_handle &&)=delete
const char * get_expected_charset()
Get the expected charset.
Definition: statement.h:264
void set_use_thd_protocol(bool use_thd_protocol)
Set thd protocol to enable result pass through.
Definition: statement.h:226
Result_set * get_current_result_set()
Get the current result set object.
Definition: statement.h:154
ulonglong warning_count() const
Get number of warnings generated.
Definition: statement.h:133
CHARSET_INFO * m_expected_charset
Definition: statement.h:324
void set_thd_protocol()
Set either Protocol_local_v2 when m_use_thd_protocol is not set or or classical protocol when m_use_t...
Definition: statement.cc:517
bool is_error() const
Check if error is reported.
Definition: statement.h:90
Statement_handle(THD *thd, const char *query, size_t length)
Definition: statement.cc:464
void copy_warnings()
Copy the warnings generated for the query from the diagnostics area.
Definition: statement.cc:476
virtual bool is_executed_or_prepared()=0
Check if the statement has been executed or prepared.
virtual bool execute()=0
Execute the SQL command.
Warning * m_warnings
Definition: statement.h:303
Result_set * m_result_sets
Definition: statement.h:311
bool is_using_thd_protocol() const
Check if thd protocol is used.
Definition: statement.h:236
Diagnostics_area * m_diagnostics_area
Definition: statement.h:305
virtual bool is_prepared_statement()=0
Check if we are processing a prepared statement.
void send_statement_status()
Send statement execution status after execute().
Definition: statement.cc:254
virtual ~Statement_handle()
Destroy the Statement_handle object.
Definition: statement.h:289
LEX_CSTRING get_last_error()
Check if error is reported.
Definition: statement.h:97
Protocol * m_saved_protocol
Definition: statement.h:344
Result_set * get_result_sets()
Get the next result sets generated while executing the statement.
Definition: statement.h:147
void add_result_set(Result_set *result_set)
Definition: statement.cc:455
bool m_use_thd_protocol
Definition: statement.h:319
void set_result_set(Result_set *result_set)
Definition: statement.cc:513
void set_expected_charset(const char *charset_name)
Set the expected charset.
Definition: statement.h:254
unsigned int get_last_errno() const
Get the last mysql errno.
Definition: statement.h:110
void reset_thd_protocol()
Reset THD protocol.
Definition: statement.cc:546
std::string m_query
Definition: statement.h:299
std::string_view get_query()
Get the query string being executed.
Definition: statement.h:202
size_t m_num_rows_per_fetch
Definition: statement.h:322
Statement_handle(const Statement_handle &)=delete
MEM_ROOT m_warning_mem_root
Definition: statement.h:302
THD * m_thd
Definition: statement.h:308
size_t get_capacity()
Get the capacity in bytes allowed for caching results.
Definition: statement.h:218
Warning * get_warnings()
Get list of all warnings.
Definition: statement.cc:506
Protocol_local_v2 m_protocol
Definition: statement.h:340
void free_old_result()
Feel all the result collected so far, from query execution.
Definition: statement.cc:508
Statement_handle & operator=(const Statement_handle &)=delete
LEX_CSTRING get_mysql_state()
Get the mysql error state.
Definition: statement.h:120
ulonglong m_warnings_count
Definition: statement.h:304
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
unsigned short m_regular_statement_handle_count
Count of Regular Statement Handles in use.
Definition: sql_class.h:4848
Class representing a warning.
Definition: warning.h:41
enum_field_types
Column types for MySQL Note: Keep include/mysql/components/services/bits/stored_program_bits....
Definition: field_types.h:55
CHARSET_INFO * get_charset_by_csname(const char *cs_name, uint cs_flags, myf my_flags)
Definition: charset.cc:343
static constexpr uint32_t MY_CS_PRIMARY
Definition: m_ctype.h:122
MYSQL_PLUGIN_IMPORT CHARSET_INFO * system_charset_info
Definition: mysqld.cc:1554
This file follows Google coding style, except for the name MEM_ROOT (which is kept for historical rea...
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
#define MYF(v)
Definition: my_inttypes.h:97
static char * query
Definition: myisam_ftdump.cc:47
Time declarations shared between the server and client API: you should not add anything to this heade...
std::function< void(const Type)> Function
Definition: ut0counter.h:241
constexpr value_type is_unsigned
Definition: classic_protocol_constants.h:273
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
PSI_memory_key key_memory_prepared_statement_main_mem_root
Definition: psi_memory_key.cc:129
required string type
Definition: replication_group_member_actions.proto:34
LEX_CSTRING convert_and_store(MEM_ROOT *mem_root, const char *str, size_t length, const CHARSET_INFO *src_cs, const CHARSET_INFO *dst_cs)
Potentially convert a string from src charset to destination charset and store the returned string on...
Definition: utils.cc:72
Declarations for implementation of server side cursors.
case opt name
Definition: sslopt-case.h:29
void init_statement_handle_interface_psi_keys()
Initializes Statement Handles PFS statement instrumentation information instances.
Definition: statement.cc:145
static constexpr unsigned short MAX_REGULAR_STATEMENT_HANDLES_LIMIT
Max limit for Regular Statement Handles in use.
Definition: statement.h:52
int dummy_function_to_ensure_we_are_linked_into_the_server()
There must be one function of this kind in order for the symbols in the server's dynamic library to b...
Definition: statement.cc:51
Definition: m_ctype.h:421
const char * csname
Definition: m_ctype.h:426
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
Statement instrument information.
Definition: psi_statement_bits.h:133
Definition: com_data.h:46