222size_t err_conv(
char *buff,
size_t to_length,
const char *from,
232 str->length(),
str->charset());
576 bool copy_conditions);
707 uint code,
const char *message_text);
725 uint code,
const char *format, ...)
726 MY_ATTRIBUTE((format(printf, 4, 5)));
748 const
char *new_syntax);
791 return s[0] ==
'0' && s[1] ==
'0';
804 return s[0] ==
'0' && s[1] ==
'1';
817 return s[0] ==
'0' && s[1] ==
'2';
830 return s[0] !=
'0' || s[1] >
'2';
835 const char *option =
nullptr);
837 const char *option =
nullptr);
Stores status of the currently executed statement.
Definition: sql_error.h:269
void reserve_number_of_conditions(THD *thd, uint count)
Make sure there is room for the given number of conditions.
Definition: sql_error.cc:597
void set_error_status(THD *thd, uint mysql_errno)
Set ERROR status in the Diagnostics Area.
Definition: sql_error.cc:423
void inc_current_row_for_condition()
Increment the current row counter to point at the next row.
Definition: sql_error.h:458
uint m_message_text_length
Length, in bytes, of m_message_text.
Definition: sql_error.h:636
Sql_condition * push_warning(THD *thd, uint mysql_errno, const char *returned_sqlstate, Sql_condition::enum_severity_level severity, const char *message_text)
Add a new SQL-condition to the current list and increment the respective counters.
Definition: sql_error.cc:604
bool is_ok() const
Definition: sql_error.h:370
ulong error_count(THD *thd) const
The number of errors, or number of rows returned by SHOW ERRORS, also the value of session variable @...
Definition: sql_error.cc:518
uint last_statement_cond_count() const
Definition: sql_error.h:406
bool is_sent() const
Definition: sql_error.h:302
ulong current_row_for_condition() const
Return the current counter value.
Definition: sql_error.h:453
void reset_condition_info(THD *thd)
Reset the current condition information stored in the Diagnostics Area.
Definition: sql_error.cc:491
ulong m_current_row_for_condition
Row counter, to print in errors and warnings.
Definition: sql_error.h:693
void set_eof_status(THD *thd)
Set EOF status.
Definition: sql_error.cc:402
const char * get_first_condition_message()
Definition: sql_error.cc:485
void disable_status()
Mark the Diagnostics Area as 'DISABLED'.
Definition: sql_error.h:352
void set_ok_status(ulonglong affected_rows, ulonglong last_insert_id, const char *message_text)
Set OK status – ends commands that do not return a result set, e.g.
Definition: sql_error.cc:378
void set_is_sent(bool is_sent)
Definition: sql_error.h:304
bool m_is_sent
True if status information is sent to the client.
Definition: sql_error.h:608
enum_diagnostics_status m_status
Definition: sql_error.h:616
void mark_preexisting_sql_conditions()
Mark current SQL-conditions so that we can later know which SQL-conditions have been added.
Definition: sql_error.cc:560
Diagnostics_area(bool allow_unlimited_conditions)
Definition: sql_error.cc:337
bool is_error() const
Definition: sql_error.h:366
Sql_condition_list::Const_Iterator Sql_condition_iterator
Const iterator used to iterate through the condition list.
Definition: sql_error.h:280
uint m_mysql_errno
SQL error number.
Definition: sql_error.h:648
MEM_ROOT m_condition_root
A memory root to allocate conditions.
Definition: sql_error.h:599
~Diagnostics_area()
Definition: sql_error.cc:359
uint m_current_statement_cond_count
The number of conditions of the current statement.
Definition: sql_error.h:684
Diagnostics_area * m_stacked_da
Pointer to the Diagnostics Area below on the stack.
Definition: sql_error.h:596
ulong current_statement_cond_count() const
Return the number of conditions raised by the current statement.
Definition: sql_error.h:412
uint m_last_statement_cond_count
Number of conditions of this last statement.
Definition: sql_error.h:676
void reset_diagnostics_area()
Clear this Diagnostics Area.
Definition: sql_error.cc:361
enum_diagnostics_status
Definition: sql_error.h:282
@ DA_OK
Set whenever one calls my_ok().
Definition: sql_error.h:286
@ DA_EMPTY
The area is cleared at start of a statement.
Definition: sql_error.h:284
@ DA_ERROR
Set whenever one calls my_error() or my_message().
Definition: sql_error.h:290
@ DA_DISABLED
Set in case of a custom response, such as one from COM_STMT_PREPARE.
Definition: sql_error.h:292
@ DA_EOF
Set whenever one calls my_eof().
Definition: sql_error.h:288
void set_current_row_for_condition(ulong rowno)
Set the current row counter to point to the given row number.
Definition: sql_error.h:461
void copy_new_sql_conditions(THD *thd, const Diagnostics_area *src_da)
Copy SQL-conditions that have been added since mark_preexisting_sql_conditions() was called.
Definition: sql_error.cc:568
ulong m_saved_warn_count
Save @warning_count before pre-clearing the DA.
Definition: sql_error.h:699
void copy_non_errors_from_da(THD *thd, const Diagnostics_area *src_da)
Copy Sql_conditions that are not SL_ERROR from the source Diagnostics Area to the current Diagnostics...
Definition: sql_error.cc:547
void set_overwrite_status(bool can_overwrite_status)
Definition: sql_error.h:298
List< const Sql_condition > m_preexisting_sql_conditions
List of conditions present in DA at handler activation.
Definition: sql_error.h:605
Diagnostics_area * pop_diagnostics_area()
Pop "this" off the Diagnostics Area stack.
Definition: sql_error.cc:643
enum_diagnostics_status status() const
Definition: sql_error.h:374
bool is_disabled() const
Definition: sql_error.h:372
const char * message_text() const
Definition: sql_error.h:376
bool m_allow_unlimited_conditions
Indicates if push_warning() allows unlimited number of conditions.
Definition: sql_error.h:614
I_P_List< Sql_condition, I_P_List_adapter< Sql_condition, &Sql_condition::m_next_condition, &Sql_condition::m_prev_condition >, I_P_List_counter, I_P_List_fast_push_back< Sql_condition > > Sql_condition_list
The type of the counted and doubly linked list of conditions.
Definition: sql_error.h:276
uint mysql_errno() const
Definition: sql_error.h:386
Sql_condition_list m_conditions_list
List of conditions of all severities.
Definition: sql_error.h:602
ulonglong last_insert_id() const
Definition: sql_error.h:401
Sql_condition * error_condition() const
Definition: sql_error.cc:584
uint m_current_statement_cond_count_by_qb[(uint) Sql_condition::SEVERITY_END]
A break down of the number of conditions per severity (level).
Definition: sql_error.h:687
void reset_statement_cond_count()
Reset between two COM_ commands.
Definition: sql_error.h:421
void copy_sql_conditions_from_da(THD *thd, const Diagnostics_area *src_da)
Copy all SQL-conditions from src_da to this DA.
Definition: sql_error.cc:536
uint cond_count() const
The number of conditions (errors, warnings and notes) in the list.
Definition: sql_error.h:483
const char * returned_sqlstate() const
Definition: sql_error.h:391
ulonglong affected_rows() const
Definition: sql_error.h:396
void reset_current_row_for_condition()
Reset the current row counter.
Definition: sql_error.h:466
bool m_can_overwrite_status
Set to make set_error_status after set_{ok,eof}_status possible.
Definition: sql_error.h:611
char m_returned_sqlstate[SQLSTATE_LENGTH+1]
SQL RETURNED_SQLSTATE condition item.
Definition: sql_error.h:642
bool is_set() const
Definition: sql_error.h:364
Sql_condition_iterator sql_conditions() const
Definition: sql_error.h:485
ulong m_saved_error_count
Save @error_count before pre-clearing the DA.
Definition: sql_error.h:696
bool is_eof() const
Definition: sql_error.h:368
ulong warn_count(THD *thd) const
Used for @warning_count system variable, which prints the number of rows returned by SHOW WARNINGS.
Definition: sql_error.cc:524
const Diagnostics_area * stacked_da() const
Returns the Diagnostics Area below the current diagnostics area on the stack.
Definition: sql_error.h:592
void push_diagnostics_area(THD *thd, Diagnostics_area *da, bool copy_conditions)
Push the given Diagnostics Area on top of the stack.
Definition: sql_error.cc:632
char m_message_text[MYSQL_ERRMSG_SIZE]
Message buffer.
Definition: sql_error.h:631
ulonglong m_last_insert_id
Similarly to the previous member, this is a replacement of thd->first_successful_insert_id_in_prev_st...
Definition: sql_error.h:668
uint message_text_length() const
Definition: sql_error.h:381
bool has_sql_condition(const char *message_text, size_t message_length) const
Checks if the condition list contains SQL-condition with the given message.
Definition: sql_error.cc:462
ulonglong m_affected_rows
The number of rows affected by the last statement.
Definition: sql_error.h:661
Definition: sql_error.h:225
ErrConvString(const char *str, size_t length)
Definition: sql_error.h:235
size_t length() const
Definition: sql_error.h:258
ErrConvString(const String *str)
Definition: sql_error.h:230
const char * ptr() const
Definition: sql_error.h:257
char err_buffer[MYSQL_ERRMSG_SIZE]
Definition: sql_error.h:226
ErrConvString(longlong nr)
Definition: sql_error.h:244
size_t buf_length
Definition: sql_error.h:227
ErrConvString(const char *str, size_t length, const CHARSET_INFO *cs)
Definition: sql_error.h:240
ErrConvString(longlong nr, bool unsigned_flag)
Definition: sql_error.h:248
Element counting policy class for I_P_List which provides basic element counting.
Definition: sql_plist.h:222
uint elements() const
Definition: sql_plist.h:233
An insertion policy class for I_P_List which can be used when fast push_back() operation is required.
Definition: sql_plist.h:260
Iterator for I_P_List.
Definition: sql_plist.h:168
Intrusive parameterized list.
Definition: sql_plist.h:75
Definition: sql_list.h:467
Sql_cmd_common_signal represents the common properties of the SIGNAL and RESIGNAL statements.
Definition: sql_signal.h:88
Sql_cmd_resignal represents a RESIGNAL statement.
Definition: sql_signal.h:168
Sql_cmd_signal represents a SIGNAL statement.
Definition: sql_signal.h:148
Representation of a SQL condition.
Definition: sql_error.h:58
String m_catalog_name
SQL CATALOG_NAME condition item.
Definition: sql_error.h:183
Sql_condition(MEM_ROOT *mem_root)
Constructor.
Definition: sql_error.cc:221
String m_cursor_name
SQL CURSOR_NAME condition item.
Definition: sql_error.h:195
String m_message_text
Message text, expressed in the character set implied by –lc-messages.
Definition: sql_error.h:198
void set_message_text(const char *message_text)
Set the condition message test.
Definition: sql_error.cc:282
size_t message_octet_length() const
Get the MESSAGE_OCTET_LENGTH of this condition.
Definition: sql_error.h:75
String m_schema_name
SQL SCHEMA_NAME condition item.
Definition: sql_error.h:186
String m_table_name
SQL TABLE_NAME condition item.
Definition: sql_error.h:189
String m_constraint_name
SQL CONSTRAINT_NAME condition item.
Definition: sql_error.h:180
void set_returned_sqlstate(const char *sqlstate)
Set the RETURNED_SQLSTATE of this condition.
Definition: sql_error.h:158
const char * message_text() const
Get the MESSAGE_TEXT of this condition.
Definition: sql_error.h:69
MEM_ROOT * m_mem_root
Memory root to use to hold condition item values.
Definition: sql_error.h:217
String m_class_origin
SQL CLASS_ORIGIN condition item.
Definition: sql_error.h:168
Sql_condition * m_next_condition
Pointers for participating in the list of conditions.
Definition: sql_error.h:213
String m_constraint_schema
SQL CONSTRAINT_SCHEMA condition item.
Definition: sql_error.h:177
uint mysql_errno() const
Get the MYSQL_ERRNO of this condition.
Definition: sql_error.h:87
void copy_opt_attributes(const Sql_condition *cond)
Copy optional condition items attributes.
Definition: sql_error.cc:268
enum_severity_level
Enumeration value describing the severity of the condition.
Definition: sql_error.h:63
@ SL_NOTE
Definition: sql_error.h:63
@ SL_ERROR
Definition: sql_error.h:63
@ SL_WARNING
Definition: sql_error.h:63
@ SEVERITY_END
Definition: sql_error.h:63
Sql_condition::enum_severity_level m_severity_level
Severity (error, warning, note) of this condition.
Definition: sql_error.h:210
String m_subclass_origin
SQL SUBCLASS_ORIGIN condition item.
Definition: sql_error.h:171
char m_returned_sqlstate[SQLSTATE_LENGTH+1]
SQL RETURNED_SQLSTATE condition item.
Definition: sql_error.h:207
void set_class_origins()
Set the CLASS_ORIGIN and SUBCLASS_ORIGIN of this condition.
Definition: sql_error.cc:293
Sql_condition::enum_severity_level severity() const
Get the severity level of this condition.
Definition: sql_error.h:93
~Sql_condition()=default
Destructor.
const char * returned_sqlstate() const
Get the RETURNED_SQLSTATE of this condition.
Definition: sql_error.h:81
String m_constraint_catalog
SQL CONSTRAINT_CATALOG condition item.
Definition: sql_error.h:174
uint m_mysql_errno
MySQL extension, MYSQL_ERRNO condition item.
Definition: sql_error.h:201
String m_column_name
SQL COLUMN_NAME condition item.
Definition: sql_error.h:192
Sql_condition ** m_prev_condition
Definition: sql_error.h:214
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:167
const char * ptr() const
Definition: sql_string.h:249
size_t length() const
Definition: sql_string.h:241
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
my_decimal class limits 'decimal_t' type to what we need in MySQL.
Definition: my_decimal.h:95
Definition: sp_rcontext.h:77
static MEM_ROOT mem_root
Definition: client_plugin.cc:114
static const std::string dec("DECRYPTION")
static constexpr unsigned PSI_INSTRUMENT_ME
Definition: psi_bits.h:43
MYSQL_STRINGS_EXPORT char * longlong10_to_str(int64_t val, char *dst, int radix)
Converts a 64-bit integer to its string representation in decimal notation.
Definition: int2str.cc:98
A better implementation of the UNIX ctype(3) library.
MYSQL_STRINGS_EXPORT CHARSET_INFO my_charset_latin1
Definition: ctype-latin1.cc:366
This file follows Google coding style, except for the name MEM_ROOT (which is kept for historical rea...
Header for compiler-dependent features.
Some integer typedefs for easier portability.
unsigned long long int ulonglong
Definition: my_inttypes.h:56
long long int longlong
Definition: my_inttypes.h:55
static int count
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:881
#define SQLSTATE_LENGTH
Definition: mysql_com.h:75
const char * collation
Definition: audit_api_message_emit.cc:184
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1081
Definition: commit_order_queue.h:34
required uint32 status
Definition: replication_asynchronous_connection_failover.proto:61
const LEX_CSTRING warning_level_names[]
Definition: sql_error.cc:727
size_t err_conv(char *buff, size_t to_length, const char *from, size_t from_length, const CHARSET_INFO *from_cs)
Convert value for dispatch to error message(see WL#751).
Definition: sql_error.cc:848
bool is_sqlstate_completion(const char *s)
Checks if the specified SQL-state-string defines COMPLETION condition.
Definition: sql_error.h:790
void check_deprecated_datetime_format(THD *thd, const CHARSET_INFO *cs, MYSQL_TIME_STATUS &status)
Check if status contains a deprecation warning.
Definition: sql_error.cc:1067
bool is_sqlstate_not_found(const char *s)
Checks if the specified SQL-state-string defines NOT FOUND condition.
Definition: sql_error.h:816
void push_deprecated_warn_no_replacement(THD *thd, const char *old_syntax)
Generates a warning that a feature is deprecated.
Definition: sql_lexer_error.h:45
void warn_on_deprecated_collation(THD *thd, const CHARSET_INFO *collation, const char *option=nullptr)
Output warnings on deprecated character collations.
Definition: sql_lexer_error.h:38
void push_warning(THD *thd, Sql_condition::enum_severity_level severity, uint code, const char *message_text)
Push the warning to error list if there is still room in the list.
Definition: sql_error.cc:659
size_t convert_error_message(char *to, size_t to_length, const CHARSET_INFO *to_cs, const char *from, size_t from_length, const CHARSET_INFO *from_cs, uint *errors)
Convert string for dispatch to client(see WL#751).
Definition: sql_error.cc:905
bool is_sqlstate_exception(const char *s)
Checks if the specified SQL-state-string defines EXCEPTION condition.
Definition: sql_error.h:829
void push_warning_printf(THD *thd, Sql_condition::enum_severity_level severity, uint code, const char *format,...)
Push the warning to error list if there is still room in the list.
Definition: sql_error.cc:690
bool mysqld_show_warnings(THD *thd, ulong levels_to_show)
Send all notes, errors or warnings to the client in a result set.
Definition: sql_error.cc:742
void push_deprecated_warn(THD *thd, const char *old_syntax, const char *new_syntax)
Generates a warning that a feature is deprecated.
Definition: sql_lexer_error.h:42
constexpr const size_t WARN_ALLOC_BLOCK_SIZE
Definition: sql_error.h:49
bool is_sqlstate_warning(const char *s)
Checks if the specified SQL-state-string defines WARNING condition.
Definition: sql_error.h:803
bool is_sqlstate_valid(const LEX_STRING *sqlstate)
Sanity check for SQLSTATEs.
Definition: sql_error.cc:971
void warn_on_deprecated_charset(THD *thd, const CHARSET_INFO *cs, const char *alias, const char *option=nullptr)
Output warnings on deprecated character sets.
Definition: sql_lexer_error.h:33
Our own string classes, used pervasively throughout the executor.
Definition: m_ctype.h:423
Hook class which via its methods specifies which members of T should be used for participating in a i...
Definition: sql_plist.h:198
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: mysql_lex_string.h:35
Structure to return status from str_to_datetime(), str_to_time(), number_to_datetime(),...
Definition: my_time.h:170
Definition: mysql_time.h:82