MySQL 9.4.0
Source Code Documentation
statement.h
Go to the documentation of this file.
1/* Copyright (c) 2023, 2025, Oracle and/or its affiliates.
2
3This program is free software; you can redistribute it and/or modify
4it under the terms of the GNU General Public License, version 2.0,
5as published by the Free Software Foundation.
6
7This program is designed to work with certain software (including
8but not limited to OpenSSL) that is licensed under separate terms,
9as designated in a particular file or component or in included license
10documentation. The authors of MySQL hereby grant you an additional
11permission to link the program and your derivative works with the
12separately licensed software that they have either included with
13the program or referenced in the documentation.
14
15This program is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18GNU General Public License, version 2.0, for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef RUN_COMMAND_H
25#define RUN_COMMAND_H
26
27#include <cstddef>
28#include <forward_list>
29#include <new>
30#include <string>
31#include <string_view>
32
33#include "lex_string.h"
34#include "my_alloc.h"
35#include "my_inttypes.h"
36#include "mysql_time.h"
37#include "sql/current_thd.h"
38#include "sql/sql_class.h"
39#include "sql/sql_cursor.h"
40#include "sql/sql_prepare.h" // Prepared_statement
43#include "utils.h"
44
45/**
46 There must be one function of this kind in order for the symbols in the
47 server's dynamic library to be visible to components.
48*/
50
51/// Max limit for Regular Statement Handles in use.
52static constexpr unsigned short MAX_REGULAR_STATEMENT_HANDLES_LIMIT{1024};
53
54/**
55 Number of PSI_statement_info instruments for Statement handles.
56*/
57#define STMT_HANDLE_PSI_STATEMENT_INFO_COUNT 6
58
59#ifdef HAVE_PSI_INTERFACE
60/**
61 Initializes Statement Handles PFS statement instrumentation information
62 instances.
63*/
65#endif
66
67/**
68 * @brief Statement_handle is similar to Ed_connection. Some of the
69 * limitations in Ed_connection is that,
70 * - It does not support reading result metadata
71 * - It does not support prepared statement, parameters and cursors.
72 *
73 * Above limitation leads to implementation of this interface.
74 *
75 * Statement_handle supports both execution of regular and
76 * prepared statement.
77 *
78 * Note that we can get rid of Ed_connection implementation
79 * as we support more functionality with Statement_handle.
80 */
82 public:
83 Statement_handle(THD *thd, const char *query, size_t length);
84
85 /**
86 * @brief Check if error is reported.
87 *
88 * @return true of error is reported.
89 */
90 bool is_error() const { return m_diagnostics_area->is_error(); }
91
92 /**
93 * @brief Check if error is reported.
94 *
95 * @return true of error is reported.
96 */
98 assert(is_error());
103 }
104
105 /**
106 * @brief Get the last mysql errno.
107 *
108 * @return unsigned int
109 */
110 unsigned int get_last_errno() const {
111 assert(is_error());
113 }
114
115 /**
116 * @brief Get the mysql error state.
117 *
118 * @return const char*
119 */
121 assert(is_error());
126 }
127
128 /**
129 * @brief Get number of warnings generated.
130 *
131 * @return ulonglong
132 */
134
135 /**
136 * @brief Get list of all warnings.
137 *
138 * @return Warning*
139 */
141
142 /**
143 * @brief Set the flag to indicate clear diagnostics area on successful
144 * execution of a statement.
145 *
146 * @param clear_da If false, the diagnostics area is not cleared on
147 * successful execution of a statement. Otherwise, the
148 * diagnostics area is cleared.
149 */
152 }
153
154 /**
155 * @brief Get value of a flag which indicates whether diagnostics area should
156 * be cleared on successful execution of a statement or not.
157 *
158 * @returns Value of a flag.
159 */
162 }
163
164 /**
165 * @brief Get the next result sets generated while executing the statement.
166 *
167 * @return Result_set*
168 */
170
171 /**
172 * @brief Get the current result set object
173 *
174 * @return Result_set*
175 */
177
178 /**
179 * @brief Make the next result set the current result set.
180 * We do it once we have read the current result set.
181 *
182 */
184 auto next_rset = m_current_rset->get_next();
185 m_current_rset = next_rset;
186 }
187
188 /**
189 * @brief Execute the SQL command.
190 * This can be either Regular or Prepared statement.
191 *
192 * @return true upon failure.
193 * @return false upon success.
194 */
195 virtual bool execute() = 0;
196
197 /**
198 * @brief Check if we are processing a prepared statement.
199 *
200 * @return true upon failure.
201 * @return false upon success.
202 */
203 virtual bool is_prepared_statement() = 0;
204
205 /**
206 * @brief Check if the statement has been executed or prepared
207 *
208 * @return true upon executed or prepared
209 * @return false otherwise
210 */
211 virtual bool is_executed_or_prepared() = 0;
212
213 /**
214 * @brief Feel all the result collected so far, from query execution.
215 *
216 */
217 void free_old_result();
218
219 /**
220 * @brief Get the query string being executed.
221 *
222 * @return std::string_view
223 */
224 std::string_view get_query() { return m_query; }
225
226 /**
227 * @brief Set the capacity in bytes allowed for caching results.
228 *
229 * @param capacity of the result set
230 */
231 void set_capacity(size_t capacity) {
233 }
234
235 /**
236 * @brief Get the capacity in bytes allowed for caching results.
237 *
238 * @return size_t
239 */
241
242 /**
243 * @brief Set thd protocol to enable result pass through.
244 *
245 * @param use_thd_protocol - parameter that decides if THD protocol should be
246 * used
247 */
248 void set_use_thd_protocol(bool use_thd_protocol) {
249 m_use_thd_protocol = use_thd_protocol;
250 }
251
252 /**
253 * @brief Check if thd protocol is used.
254 *
255 * @return true if enabled.
256 * @return false if not.
257 */
259
260 /**
261 * @brief Set either Protocol_local_v2 when m_use_thd_protocol is not set or
262 * or classical protocol when m_use_thd_protocol is set to THD.
263 */
264 void set_thd_protocol();
265
266 /**
267 * @brief Reset THD protocol.
268 */
269 void reset_thd_protocol();
270
271 /**
272 * @brief Set the expected charset
273 *
274 * @param charset_name Name of the charset
275 */
276 void set_expected_charset(const char *charset_name) {
278 get_charset_by_csname(charset_name, MY_CS_PRIMARY, MYF(0));
279 }
280
281 /**
282 * @brief Get the expected charset
283 *
284 * @return const char* the expected charset name
285 */
286 const char *get_expected_charset() {
287 if (m_expected_charset == nullptr) return nullptr;
289 }
290
291 /**
292 * @brief Get the num rows per fetch.
293 *
294 * @return size_t
295 */
297
298 /**
299 * @brief Set the num of rows to be retrieved per fetch.
300 *
301 * @param num_rows_per_fetch number of rows per fetch
302 */
303 void set_num_rows_per_fetch(size_t num_rows_per_fetch) {
304 m_num_rows_per_fetch = num_rows_per_fetch;
305 }
306
307 /**
308 * @brief Destroy the Statement_handle object
309 *
310 */
312
313 protected:
314 /**
315 * @brief Send statement execution status after execute().
316 */
318
319 protected:
320 // The query being executed.
321 std::string m_query;
322
323 // Details about error or warning occurred.
327
329
330 /// Flag to indicate if diagnostics area should be cleared or retained on
331 /// successful execution of a statement.
332 /// If retained, then user of this class should manage diagnostics area.
334
335 // The thread executing the statement.
337
338 // List of all results generated by the query.
340
341 // The last result generated by the guery.
343
344 // Do not intercept the results in the protocol, but pass it to
345 // THD* protocol. E.g., if this is set to 'false', the results are
346 // captured into Protocol_result_v2, else it goes to THD->get_protocol()
347 bool m_use_thd_protocol = false;
348
349 // Max rows to read per fetch() call.
351
353
354 // Collect result set from single statement.
356
357 // Set result set from prepared statement with cursor.
358 // This is called at the end of fetch().
360
361 /**
362 * @brief Copy the warnings generated for the query from the
363 * diagnostics area
364 */
365 void copy_warnings();
366
367 // Protocol that intercepts all the rows from query executed.
369 friend class Protocol_local_v2;
370
371 // Protocol used by THD before switching.
373
374 // No copies.
376 // No move.
378 // No self assignment.
380 // No move.
382};
383
384/**
385 * @brief Regular_statement_handle enables execution of all SQL statements
386 * except for prepared statements.
387 */
389 public:
390 Regular_statement_handle(THD *thd, const char *query, uint length)
391 : Statement_handle(thd, query, length) {}
392
395 }
396
397 /**
398 * @brief Execute a regular statement.
399 *
400 * @return true if statement fails.
401 * @return false if statement succeeds.
402 */
403 bool execute() override;
404
405 /**
406 * @brief Convey that this is regular statement.
407 *
408 * @return Always returns 'false'
409 */
410 bool is_prepared_statement() override { return false; }
411
412 /**
413 * @brief Check if the statement has been executed
414 *
415 * @return true if executed
416 * @return false otherwise
417 */
418 bool is_executed_or_prepared() override { return m_is_executed; }
419
420 public:
421#ifdef HAVE_PSI_INTERFACE
422 // PSI_statement_info instances for regular statement handle.
424#endif
425
426 private:
427 /// Flag to indicate if statement has been executed. Set to true in execute().
428 bool m_is_executed = false;
429
430 // Used by execute() above.
431 bool execute(Server_runnable *server_runnable);
432};
433
434/**
435 * @brief Prepared_statement_handle enables support for prepared
436 * statement execution. Supports parameters and cursors.
437 */
439 public:
440 Prepared_statement_handle(THD *thd, const char *query, uint length)
443 thd->variables.query_alloc_block_size) {}
444
445 /**
446 * @brief Prepares the statement using m_query.
447 *
448 * If the statement is already in executing mode, close the cursor
449 * deallocate the previous statement and start preparing new statement
450 * using m_query.
451 *
452 * @return true if fails.
453 * @return false if succeeds.
454 */
455 bool prepare();
456
457 /**
458 * @brief Set the parameter value in a prepared statement.
459 *
460 * @param idx Index of '?' in prepared statement.
461 * @param is_null Set parameter to NULL value.
462 * @param type Set the parameters field type.
463 * @param is_unsigned Mark parameter as unsigned.
464 * @param data Pointer to buffer containing the value.
465 * @param data_length Length of buffer 'data'
466 * @param name Name of parameter (mostly unused)
467 * @param name_length Length of 'name'
468 *
469 * @return true if fails.
470 * @return false if succeeds.
471 */
472 bool set_parameter(uint idx, bool is_null, enum_field_types type,
473 bool is_unsigned, const void *data,
474 unsigned long data_length, const char *name,
475 unsigned long name_length);
476
477 /**
478 * @brief Get the parameter object
479 *
480 * @param index of the parameter
481 * @return Item_param*
482 */
484
485 /**
486 * @brief Execute the statement that is prepared.
487 *
488 * If a statement is not yet prepared, we fail.
489 *
490 * If a statement was already in EXECUTED state, we close the cursor
491 * and execute the statement again.
492 *
493 * @return true
494 * @return false
495 */
496 bool execute() override;
497
498 /**
499 * @brief Fetch rows from statement using cursor.
500 *
501 * Not all statement uses cursor. Check is_cursor_open() and
502 * then invoke this call.
503 *
504 * Attempt to call fetch rows without preparing or executing the
505 * statement will cause failure.
506 *
507 * Attempt to call fetch() without cursor in use, will cause failure.
508 *
509 * @return true
510 * @return false
511 */
512 bool fetch();
513
514 /**
515 * @brief Check if the statement uses cursor and it is open.
516 *
517 * If the API is called without preparing the statement will
518 * result in 'false'
519 *
520 * @return true if cursor is in use
521 * @return false if cursor not in use.
522 */
524 if (!m_stmt) return false;
525 return m_stmt->m_cursor && m_stmt->m_cursor->is_open();
526 }
527
528 /**
529 * @brief Check if the statement uses cursor.
530 *
531 * If the API is called without executing the statement
532 * will result in 'false'
533 *
534 * @return true if statement uses cursor.
535 * @return false if statement does not uses cursor.
536 */
537 bool uses_cursor() {
539 return false;
540 return m_stmt->m_cursor != nullptr;
541 }
542
543 /**
544 * @brief Reset the statement parameters and cursors.
545 *
546 * Invoking this API will close the cursor in use.
547 * This is invoked generally before executing
548 * the statement for the second time, after prepare.
549 *
550 * @return true
551 * @return false
552 */
553 bool reset();
554
555 /**
556 * @brief Close the statement that is prepared.
557 *
558 * @return true
559 * @return false
560 */
561 bool close();
562
563 /**
564 * @brief Get number of parameters used in the statement.
565 *
566 * This should be called after preparing a statement.
567 *
568 * @return uint
569 */
570 uint get_param_count() { return m_stmt ? m_stmt->m_param_count : 0; }
571
572 /**
573 * @brief Convey that this is prepared statement.
574 *
575 * @return Always returns true
576 */
577 bool is_prepared_statement() override { return true; }
578
579 /**
580 * @brief Check if the statement has been executed or prepared
581 *
582 * @return true if executed or prepared
583 * @return false otherwise
584 */
585 bool is_executed_or_prepared() override {
586 return m_stmt != nullptr &&
588 }
589
590 /**
591 * @brief Virtual destroy for Prepared_statement_handle object
592 *
593 */
595
596#ifdef HAVE_PSI_INTERFACE
597 // PSI_statement_info instances for prepared statement handle.
603#endif
604
605 private:
606 /**
607 * @brief This is a wrapper function used to execute
608 * and operation on Prepared_statement. This takes case of using
609 * relevant protocol, diagnostic area, backup the current query arena
610 * before executing the prepared statement operation.
611 *
612 * @tparam Function type of function to run
613 * @param exec_func function to run
614 * @param psi_info PSI_statement_info instance.
615 *
616 * @return true
617 * @return false
618 */
619 template <typename Function>
620 bool run(Function exec_func, PSI_statement_info *psi_info);
621
622 // See prepare()
623 bool internal_prepare();
624
625 // See execute()
626 bool internal_execute();
627
628 // See fetch()
629 bool internal_fetch();
630
631 // See reset()
632 bool internal_reset();
633
634 /**
635 * @brief Reset the statement parameters and cursors.
636 *
637 * @param invalidate_params When set to true parameters are invalidated.
638 *
639 * @return true on failure.
640 * @return false on execute.
641 */
642
643 bool internal_reset(bool invalidate_params);
644
645 // See close()
646 bool internal_close();
647
648 /**
649 * @brief Method to enable cursor.
650 *
651 * @return true if cursor can be used for a statement.
652 * @return false if cursor can not be used for a statement.
653 */
654 bool enable_cursor();
655
656 /**
657 * @brief Create a parameter buffers
658 *
659 * @return true on failure
660 * @return false on success
661 */
663
664 // The prepared statement implementation.
666
667 // Parameters values.
669
670 /*
671 Store the parameter and parameter values in a separate mem_root.
672 These can be even stored in m_stmt's mem_root. But reprepare() would
673 free up the memory used by the prepared statement. Hence, using separate
674 mem_root.
675 */
677
678 /*
679 Size of each parameter buffer allocated in mem_root.
680 We re-use the same buffer, if the parameter value size fit
681 within this max.
682 */
683 ulong *m_parameter_buffer_max{nullptr};
684
685 /*
686 Denotes if new parameters were set.
687 This is set 'true' for the first time. It is set to 'false' upon
688 re-execute without rebinding any parameters.
689 */
691};
692
693#endif
Stores status of the currently executed statement.
Definition: sql_error.h:270
bool is_error() const
Definition: sql_error.h:367
const char * message_text() const
Definition: sql_error.h:377
uint mysql_errno() const
Definition: sql_error.h:387
const char * returned_sqlstate() const
Definition: sql_error.h:392
Dynamic parameters used as placeholders ('?') inside prepared statements.
Definition: item.h:4793
Prepared_statement_handle enables support for prepared statement execution.
Definition: statement.h:438
Prepared_statement_handle(THD *thd, const char *query, uint length)
Definition: statement.h:440
bool reset()
Reset the statement parameters and cursors.
Definition: statement.cc:863
bool close()
Close the statement that is prepared.
Definition: statement.cc:868
bool m_bound_new_parameter_types
Definition: statement.h:690
ulong * m_parameter_buffer_max
Definition: statement.h:683
bool internal_close()
Definition: statement.cc:813
static PSI_statement_info fetch_psi_info
Definition: statement.h:600
bool is_executed_or_prepared() override
Check if the statement has been executed or prepared.
Definition: statement.h:585
static PSI_statement_info execute_psi_info
Definition: statement.h:599
bool execute() override
Execute the statement that is prepared.
Definition: statement.cc:853
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:874
static PSI_statement_info prepare_psi_info
Definition: statement.h:598
bool internal_reset()
Definition: statement.cc:779
bool create_parameter_buffers()
Create a parameter buffers.
Definition: statement.cc:936
Prepared_statement * m_stmt
Definition: statement.h:665
bool prepare()
Prepares the statement using m_query.
Definition: statement.cc:848
uint get_param_count()
Get number of parameters used in the statement.
Definition: statement.h:570
bool is_cursor_open()
Check if the statement uses cursor and it is open.
Definition: statement.h:523
bool uses_cursor()
Check if the statement uses cursor.
Definition: statement.h:537
bool internal_fetch()
Definition: statement.cc:738
bool enable_cursor()
Method to enable cursor.
Definition: statement.cc:638
static PSI_statement_info close_psi_info
Definition: statement.h:602
bool fetch()
Fetch rows from statement using cursor.
Definition: statement.cc:858
bool internal_prepare()
Definition: statement.cc:562
virtual ~Prepared_statement_handle() override
Virtual destroy for Prepared_statement_handle object.
Definition: statement.h:594
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:967
Item_param * get_parameter(size_t index)
Get the parameter object.
Definition: statement.cc:1019
MEM_ROOT m_parameter_mem_root
Definition: statement.h:676
static PSI_statement_info reset_psi_info
Definition: statement.h:601
bool internal_execute()
Definition: statement.cc:660
PS_PARAM * m_parameters
Definition: statement.h:668
bool is_prepared_statement() override
Convey that this is prepared statement.
Definition: statement.h:577
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:388
bool is_prepared_statement() override
Convey that this is regular statement.
Definition: statement.h:410
static PSI_statement_info stmt_psi_info
Definition: statement.h:423
bool m_is_executed
Flag to indicate if statement has been executed. Set to true in execute().
Definition: statement.h:428
bool execute() override
Execute a regular statement.
Definition: statement.cc:302
Regular_statement_handle(THD *thd, const char *query, uint length)
Definition: statement.h:390
bool is_executed_or_prepared() override
Check if the statement has been executed.
Definition: statement.h:418
~Regular_statement_handle() override
Definition: statement.h:393
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:296
void next_result_set()
Make the next result set the current result set.
Definition: statement.h:183
Statement_handle(Statement_handle &&)=delete
void set_capacity(size_t capacity)
Set the capacity in bytes allowed for caching results.
Definition: statement.h:231
Result_set * m_current_rset
Definition: statement.h:342
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:303
Statement_handle & operator=(Statement_handle &&)=delete
const char * get_expected_charset()
Get the expected charset.
Definition: statement.h:286
void set_use_thd_protocol(bool use_thd_protocol)
Set thd protocol to enable result pass through.
Definition: statement.h:248
Result_set * get_current_result_set()
Get the current result set object.
Definition: statement.h:176
ulonglong warning_count() const
Get number of warnings generated.
Definition: statement.h:133
CHARSET_INFO * m_expected_charset
Definition: statement.h:352
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:527
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:474
void copy_warnings()
Copy the warnings generated for the query from the diagnostics area.
Definition: statement.cc:486
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:325
Result_set * m_result_sets
Definition: statement.h:339
bool is_using_thd_protocol() const
Check if thd protocol is used.
Definition: statement.h:258
Diagnostics_area * m_diagnostics_area
Definition: statement.h:328
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:261
virtual ~Statement_handle()
Destroy the Statement_handle object.
Definition: statement.h:311
bool clear_diagnostics_area_on_success() const
Get value of a flag which indicates whether diagnostics area should be cleared on successful executio...
Definition: statement.h:160
LEX_CSTRING get_last_error()
Check if error is reported.
Definition: statement.h:97
Protocol * m_saved_protocol
Definition: statement.h:372
Result_set * get_result_sets()
Get the next result sets generated while executing the statement.
Definition: statement.h:169
void add_result_set(Result_set *result_set)
Definition: statement.cc:465
bool m_use_thd_protocol
Definition: statement.h:347
void set_result_set(Result_set *result_set)
Definition: statement.cc:523
void set_expected_charset(const char *charset_name)
Set the expected charset.
Definition: statement.h:276
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:556
std::string m_query
Definition: statement.h:321
bool m_clear_diagnostics_area_on_success
Flag to indicate if diagnostics area should be cleared or retained on successful execution of a state...
Definition: statement.h:333
std::string_view get_query()
Get the query string being executed.
Definition: statement.h:224
size_t m_num_rows_per_fetch
Definition: statement.h:350
Statement_handle(const Statement_handle &)=delete
MEM_ROOT m_warning_mem_root
Definition: statement.h:324
THD * m_thd
Definition: statement.h:336
size_t get_capacity()
Get the capacity in bytes allowed for caching results.
Definition: statement.h:240
Warning * get_warnings()
Get list of all warnings.
Definition: statement.cc:516
Protocol_local_v2 m_protocol
Definition: statement.h:368
void free_old_result()
Feel all the result collected so far, from query execution.
Definition: statement.cc:518
Statement_handle & operator=(const Statement_handle &)=delete
LEX_CSTRING get_mysql_state()
Get the mysql error state.
Definition: statement.h:120
void set_clear_diagnostics_area_on_success(bool clear_da)
Set the flag to indicate clear diagnostics area on successful execution of a statement.
Definition: statement.h:150
ulonglong m_warnings_count
Definition: statement.h:326
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:4878
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:352
static constexpr uint32_t MY_CS_PRIMARY
Definition: m_ctype.h:122
MYSQL_PLUGIN_IMPORT CHARSET_INFO * system_charset_info
Definition: mysqld.cc:1566
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
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
bool index(const std::string &value, const String &search_for, uint32_t *idx)
Definition: contains.h:76
static mysql_service_status_t result_set(UDF_INIT *, const char *, void *) noexcept
Definition: mysql_udf_metadata_all_empty.cc:53
bool is_null(poly_thread thread, poly_value value)
Definition: jit_executor_type_conversion.cc:46
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:152
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