28#include <forward_list>
391 thd->variables.query_alloc_block_size) {}
422 unsigned long data_length,
const char *
name,
423 unsigned long name_length);
472 if (!
m_stmt)
return false;
534 return m_stmt !=
nullptr &&
556 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:4757
Prepared_statement_handle enables support for prepared statement execution.
Definition: statement.h:386
Prepared_statement_handle(THD *thd, const char *query, uint length)
Definition: statement.h:388
bool reset()
Reset the statement parameters and cursors.
Definition: statement.cc:685
bool close()
Close the statement that is prepared.
Definition: statement.cc:689
bool m_bound_new_parameter_types
Definition: statement.h:627
ulong * m_parameter_buffer_max
Definition: statement.h:620
bool internal_close()
Definition: statement.cc:638
bool is_executed_or_prepared() override
Check if the statement has been executed or prepared.
Definition: statement.h:533
bool execute() override
Execute the statement that is prepared.
Definition: statement.cc:677
bool run(Function exec_func)
This is a wrapper function used to execute and operation on Prepared_statement.
Definition: statement.cc:694
bool internal_reset()
Definition: statement.cc:604
bool create_parameter_buffers()
Create a parameter buffers.
Definition: statement.cc:749
Prepared_statement * m_stmt
Definition: statement.h:602
bool prepare()
Prepares the statement using m_query.
Definition: statement.cc:673
uint get_param_count()
Get number of parameters used in the statement.
Definition: statement.h:518
bool is_cursor_open()
Check if the statement uses cursor and it is open.
Definition: statement.h:471
bool uses_cursor()
Check if the statement uses cursor.
Definition: statement.h:485
bool internal_fetch()
Definition: statement.cc:564
bool enable_cursor()
Method to enable cursor.
Definition: statement.cc:470
bool fetch()
Fetch rows from statement using cursor.
Definition: statement.cc:681
bool internal_prepare()
Definition: statement.cc:394
virtual ~Prepared_statement_handle() override
Virtual destroy for Prepared_statement_handle object.
Definition: statement.h:542
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:780
Item_param * get_parameter(size_t index)
Get the parameter object.
Definition: statement.cc:832
MEM_ROOT m_parameter_mem_root
Definition: statement.h:613
bool internal_execute()
Definition: statement.cc:492
PS_PARAM * m_parameters
Definition: statement.h:605
bool is_prepared_statement() override
Convey that this is prepared statement.
Definition: statement.h:525
Prepared_statement: a statement that can contain placeholders.
Definition: sql_prepare.h:152
Server_side_cursor * m_cursor
Pointer to cursor, may be NULL if statement never used with a cursor.
Definition: sql_prepare.h:161
Query_arena m_arena
Memory allocation arena, for permanent allocations to statement.
Definition: sql_prepare.h:155
uint m_param_count
Number of parameters expected for statement.
Definition: sql_prepare.h:167
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:345
bool is_prepared_statement() override
Convey that this is regular statement.
Definition: statement.h:363
bool m_is_executed
Definition: statement.h:376
bool execute() override
Execute a regular statement.
Definition: statement.cc:171
Regular_statement_handle(THD *thd, const char *query, uint length)
Definition: statement.h:347
bool is_executed_or_prepared() override
Check if the statement has been executed.
Definition: statement.h:371
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 extension of Ed_connection.
Definition: statement.h:66
size_t get_num_rows_per_fetch()
Get the num rows per fetch.
Definition: statement.h:259
void next_result_set()
Make the next result set the current result set.
Definition: statement.h:146
Statement_handle(Statement_handle &&)=delete
const char * get_mysql_state()
Get the mysql error state.
Definition: statement.h:105
void set_capacity(size_t capacity)
Set the capacity in bytes allowed for caching results.
Definition: statement.h:194
Result_set * m_current_rset
Definition: statement.h:299
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:266
Statement_handle & operator=(Statement_handle &&)=delete
const char * get_expected_charset()
Get the expected charset.
Definition: statement.h:249
void set_use_thd_protocol(bool use_thd_protocol)
Set thd protocol to enable result pass through.
Definition: statement.h:211
Result_set * get_current_result_set()
Get the current result set object.
Definition: statement.h:139
ulonglong warning_count() const
Get number of warnings generated.
Definition: statement.h:118
CHARSET_INFO * m_expected_charset
Definition: statement.h:309
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:301
bool is_error() const
Check if error is reported.
Definition: statement.h:75
Statement_handle(THD *thd, const char *query, size_t length)
Definition: statement.cc:248
void copy_warnings()
Copy the warnings generated for the query from the diagnostics area.
Definition: statement.cc:260
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:288
Result_set * m_result_sets
Definition: statement.h:296
bool is_using_thd_protocol() const
Check if thd protocol is used.
Definition: statement.h:221
Diagnostics_area * m_diagnostics_area
Definition: statement.h:290
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:130
virtual ~Statement_handle()
Destroy the Statement_handle object.
Definition: statement.h:274
Protocol * m_saved_protocol
Definition: statement.h:329
Result_set * get_result_sets()
Get the next result sets generated while executing the statement.
Definition: statement.h:132
void add_result_set(Result_set *result_set)
Definition: statement.cc:239
bool m_use_thd_protocol
Definition: statement.h:304
void set_result_set(Result_set *result_set)
Definition: statement.cc:297
void set_expected_charset(const char *charset_name)
Set the expected charset.
Definition: statement.h:239
unsigned int get_last_errno() const
Get the last mysql errno.
Definition: statement.h:95
void reset_thd_protocol()
Reset THD protocol.
Definition: statement.cc:330
std::string m_query
Definition: statement.h:284
std::string_view get_query()
Get the query string being executed.
Definition: statement.h:187
size_t m_num_rows_per_fetch
Definition: statement.h:307
Statement_handle(const Statement_handle &)=delete
MEM_ROOT m_warning_mem_root
Definition: statement.h:287
const char * get_last_error()
Check if error is reported.
Definition: statement.h:82
THD * m_thd
Definition: statement.h:293
size_t get_capacity()
Get the capacity in bytes allowed for caching results.
Definition: statement.h:203
Warning * get_warnings()
Get list of all warnings.
Definition: statement.cc:290
Protocol_local_v2 m_protocol
Definition: statement.h:325
void free_old_result()
Feel all the result collected so far, from query execution.
Definition: statement.cc:292
Statement_handle & operator=(const Statement_handle &)=delete
ulonglong m_warnings_count
Definition: statement.h:289
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
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:326
static constexpr uint32_t MY_CS_PRIMARY
Definition: m_ctype.h:122
MYSQL_PLUGIN_IMPORT CHARSET_INFO * system_charset_info
Definition: mysqld.cc:1542
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:128
required string type
Definition: replication_group_member_actions.proto:34
char * 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
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:423
const char * csname
Definition: m_ctype.h:428
The MEM_ROOT is a simple arena, where allocations are carved out of larger blocks.
Definition: my_alloc.h:83
Definition: com_data.h:46