MySQL 8.0.39
Source Code Documentation
|
Stores status of the currently executed statement. More...
#include <sql_error.h>
Public Types | |
enum | enum_diagnostics_status { DA_EMPTY = 0 , DA_OK , DA_EOF , DA_ERROR , DA_DISABLED } |
typedef Sql_condition_list::Const_Iterator | Sql_condition_iterator |
Const iterator used to iterate through the condition list. More... | |
Public Member Functions | |
Diagnostics_area (bool allow_unlimited_conditions) | |
~Diagnostics_area () | |
void | set_overwrite_status (bool can_overwrite_status) |
bool | is_sent () const |
void | set_is_sent (bool is_sent) |
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. More... | |
void | set_eof_status (THD *thd) |
Set EOF status. More... | |
void | set_error_status (THD *thd, uint mysql_errno) |
Set ERROR status in the Diagnostics Area. More... | |
void | set_error_status (uint mysql_errno, const char *message_text, const char *returned_sqlstate) |
Set ERROR status in the Diagnostics Area. More... | |
void | disable_status () |
Mark the Diagnostics Area as 'DISABLED'. More... | |
void | reset_diagnostics_area () |
Clear this Diagnostics Area. More... | |
bool | is_set () const |
bool | is_error () const |
bool | is_eof () const |
bool | is_ok () const |
bool | is_disabled () const |
enum_diagnostics_status | status () const |
const char * | message_text () const |
uint | message_text_length () const |
uint | mysql_errno () const |
const char * | returned_sqlstate () const |
ulonglong | affected_rows () const |
ulonglong | last_insert_id () const |
uint | last_statement_cond_count () const |
ulong | current_statement_cond_count () const |
Return the number of conditions raised by the current statement. More... | |
void | reset_statement_cond_count () |
Reset between two COM_ commands. More... | |
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. More... | |
bool | has_sql_condition (uint sql_errno) const |
Checks if the condition list contains SQL-condition with the given error code. More... | |
void | reset_condition_info (THD *thd) |
Reset the current condition information stored in the Diagnostics Area. More... | |
ulong | current_row_for_condition () const |
Return the current counter value. More... | |
void | inc_current_row_for_condition () |
Increment the current row counter to point at the next row. More... | |
void | set_current_row_for_condition (ulong rowno) |
Set the current row counter to point to the given row number. More... | |
void | reset_current_row_for_condition () |
Reset the current row counter. More... | |
ulong | error_count (THD *thd) const |
The number of errors, or number of rows returned by SHOW ERRORS, also the value of session variable @error_count. More... | |
ulong | warn_count (THD *thd) const |
Used for @warning_count system variable, which prints the number of rows returned by SHOW WARNINGS. More... | |
uint | cond_count () const |
The number of conditions (errors, warnings and notes) in the list. More... | |
Sql_condition_iterator | sql_conditions () const |
const char * | get_first_condition_message () |
void | reserve_number_of_conditions (THD *thd, uint count) |
Make sure there is room for the given number of conditions. More... | |
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. More... | |
void | mark_preexisting_sql_conditions () |
Mark current SQL-conditions so that we can later know which SQL-conditions have been added. More... | |
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. More... | |
void | copy_sql_conditions_from_da (THD *thd, const Diagnostics_area *src_da) |
Copy all SQL-conditions from src_da to this DA. More... | |
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 Area. More... | |
Sql_condition * | error_condition () const |
Private Types | |
typedef 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. More... | |
Private Member Functions | |
Sql_condition * | push_warning (THD *thd, const Sql_condition *sql_condition) |
Add a new SQL-condition to the current list and increment the respective counters. More... | |
void | push_diagnostics_area (THD *thd, Diagnostics_area *da, bool copy_conditions) |
Push the given Diagnostics Area on top of the stack. More... | |
Diagnostics_area * | pop_diagnostics_area () |
Pop "this" off the Diagnostics Area stack. More... | |
const Diagnostics_area * | stacked_da () const |
Returns the Diagnostics Area below the current diagnostics area on the stack. More... | |
Private Attributes | |
Diagnostics_area * | m_stacked_da |
Pointer to the Diagnostics Area below on the stack. More... | |
MEM_ROOT | m_condition_root {PSI_INSTRUMENT_ME, WARN_ALLOC_BLOCK_SIZE} |
A memory root to allocate conditions. More... | |
Sql_condition_list | m_conditions_list |
List of conditions of all severities. More... | |
List< const Sql_condition > | m_preexisting_sql_conditions |
List of conditions present in DA at handler activation. More... | |
bool | m_is_sent |
True if status information is sent to the client. More... | |
bool | m_can_overwrite_status |
Set to make set_error_status after set_{ok,eof}_status possible. More... | |
bool | m_allow_unlimited_conditions |
Indicates if push_warning() allows unlimited number of conditions. More... | |
enum_diagnostics_status | m_status |
char | m_message_text [MYSQL_ERRMSG_SIZE] |
Message buffer. More... | |
uint | m_message_text_length |
Length, in bytes, of m_message_text. More... | |
char | m_returned_sqlstate [SQLSTATE_LENGTH+1] |
SQL RETURNED_SQLSTATE condition item. More... | |
uint | m_mysql_errno |
SQL error number. More... | |
ulonglong | m_affected_rows |
The number of rows affected by the last statement. More... | |
ulonglong | m_last_insert_id |
Similarly to the previous member, this is a replacement of thd->first_successful_insert_id_in_prev_stmt, which is used to implement LAST_INSERT_ID(). More... | |
uint | m_last_statement_cond_count |
Number of conditions of this last statement. More... | |
uint | m_current_statement_cond_count |
The number of conditions of the current statement. More... | |
uint | m_current_statement_cond_count_by_qb [(uint) Sql_condition::SEVERITY_END] |
A break down of the number of conditions per severity (level). More... | |
ulong | m_current_row_for_condition |
Row counter, to print in errors and warnings. More... | |
ulong | m_saved_error_count |
Save @error_count before pre-clearing the DA. More... | |
ulong | m_saved_warn_count |
Save @warning_count before pre-clearing the DA. More... | |
Friends | |
class | THD |
Stores status of the currently executed statement.
Cleared at the beginning of the statement, and then can hold either OK, ERROR, or EOF status. Can not be assigned twice per statement.
Const iterator used to iterate through the condition list.
The type of the counted and doubly linked list of conditions.
Diagnostics_area::Diagnostics_area | ( | bool | allow_unlimited_conditions | ) |
Diagnostics_area::~Diagnostics_area | ( | ) |
|
inline |
|
inline |
The number of conditions (errors, warnings and notes) in the list.
void Diagnostics_area::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.
thd | Thread context. |
src_da | Diagnostics Area to copy from. |
void Diagnostics_area::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 Area.
thd | Thread context. |
src_da | Diagnostics Area to copy from. |
void Diagnostics_area::copy_sql_conditions_from_da | ( | THD * | thd, |
const Diagnostics_area * | src_da | ||
) |
Copy all SQL-conditions from src_da to this DA.
thd | Thread context. |
src_da | Diagnostics Area to copy from. |
|
inline |
Return the current counter value.
|
inline |
Return the number of conditions raised by the current statement.
|
inline |
Mark the Diagnostics Area as 'DISABLED'.
This is used in rare cases when the COM_ command at hand sends a response in a custom format. One example is COM_STMT_PREPARE.
Sql_condition * Diagnostics_area::error_condition | ( | ) | const |
ulong Diagnostics_area::error_count | ( | THD * | thd | ) | const |
The number of errors, or number of rows returned by SHOW ERRORS, also the value of session variable @error_count.
const char * Diagnostics_area::get_first_condition_message | ( | ) |
bool Diagnostics_area::has_sql_condition | ( | const char * | message_text, |
size_t | message_length | ||
) | const |
Checks if the condition list contains SQL-condition with the given message.
message_text | Message text |
message_length | Length of message_text |
bool Diagnostics_area::has_sql_condition | ( | uint | sql_errno | ) | const |
Checks if the condition list contains SQL-condition with the given error code.
sql_errno | Error code |
|
inline |
Increment the current row counter to point at the next row.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
void Diagnostics_area::mark_preexisting_sql_conditions | ( | ) |
Mark current SQL-conditions so that we can later know which SQL-conditions have been added.
|
inline |
|
inline |
|
inline |
|
private |
Pop "this" off the Diagnostics Area stack.
|
private |
Push the given Diagnostics Area on top of the stack.
"This" will then become the stacked Diagnostics Area. Conditions present in the new stacked Diagnostics Area will be copied to the new top Diagnostics Area.
thd | Thread context |
da | Diagnostics Area to be come the top of the Diagnostics Area stack. |
copy_conditions | Copy the conditions from the new second Diagnostics Area to the new first Diagnostics Area, as per SQL standard. |
|
private |
Add a new SQL-condition to the current list and increment the respective counters.
thd | Thread context. |
sql_condition | SQL-condition to copy values from. |
Sql_condition * Diagnostics_area::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.
thd | Thread context. |
mysql_errno | SQL-condition error number. |
returned_sqlstate | SQL-condition state. |
severity | SQL-condition severity. |
message_text | SQL-condition message. |
Make sure there is room for the given number of conditions.
void Diagnostics_area::reset_condition_info | ( | THD * | thd | ) |
Reset the current condition information stored in the Diagnostics Area.
Clear all conditions, the number of conditions, reset current row counter to point to the first row.
|
inline |
Reset the current row counter.
Start counting from 1.
void Diagnostics_area::reset_diagnostics_area | ( | ) |
Clear this Diagnostics Area.
Normally called at the end of a statement.
|
inline |
Reset between two COM_ commands.
Conditions are preserved between commands, but m_current_statement_cond_count indicates the number of conditions of this particular statement only.
|
inline |
|
inline |
Set the current row counter to point to the given row number.
void Diagnostics_area::set_eof_status | ( | THD * | thd | ) |
Set EOF status.
thd | Thread context. |
Set ERROR status in the Diagnostics Area.
This function should be used to report fatal errors (such as out-of-memory errors) when no further processing is possible.
thd | Thread handle |
mysql_errno | SQL-condition error number |
void Diagnostics_area::set_error_status | ( | uint | mysql_errno, |
const char * | message_text, | ||
const char * | returned_sqlstate | ||
) |
Set ERROR status in the Diagnostics Area.
mysql_errno | SQL-condition error number |
message_text | SQL-condition message |
returned_sqlstate | SQL-condition state |
|
inline |
void Diagnostics_area::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.
INSERT/UPDATE/DELETE.
affected_rows | The number of rows affected by the last statement. |
last_insert_id | The value to be returned by LAST_INSERT_ID(). |
message_text | The OK-message text. |
|
inline |
|
inline |
|
inlineprivate |
Returns the Diagnostics Area below the current diagnostics area on the stack.
|
inline |
ulong Diagnostics_area::warn_count | ( | THD * | thd | ) | const |
Used for @warning_count system variable, which prints the number of rows returned by SHOW WARNINGS.
|
friend |
|
private |
The number of rows affected by the last statement.
This is semantically close to thd->row_count_func, but has a different life cycle. thd->row_count_func stores the value returned by function ROW_COUNT() and is cleared only by statements that update its value, such as INSERT, UPDATE, DELETE and few others. This member is cleared at the beginning of the next statement.
We could possibly merge the two, but life cycle of thd->row_count_func can not be changed.
|
private |
Indicates if push_warning() allows unlimited number of conditions.
|
private |
Set to make set_error_status after set_{ok,eof}_status possible.
|
private |
A memory root to allocate conditions.
|
private |
List of conditions of all severities.
|
private |
Row counter, to print in errors and warnings.
Not increased in create_sort_index(); may differ from examined_row_count.
|
private |
The number of conditions of the current statement.
m_conditions_list life cycle differs from statement life cycle – it may span multiple statements. In that case we get m_current_statement_cond_count 0, whereas m_conditions_list is not empty.
|
private |
A break down of the number of conditions per severity (level).
|
private |
True if status information is sent to the client.
|
private |
Similarly to the previous member, this is a replacement of thd->first_successful_insert_id_in_prev_stmt, which is used to implement LAST_INSERT_ID().
|
private |
Number of conditions of this last statement.
May differ from the number of conditions returned by SHOW WARNINGS e.g. in case the statement doesn't clear the conditions, and doesn't generate them.
|
private |
Message buffer.
It is used only when DA is in OK or ERROR status. If DA status is ERROR, it's the MESSAGE_TEXT attribute of SQL-condition. If DA status is OK, it's the OK-message to be sent.
|
private |
Length, in bytes, of m_message_text.
|
private |
SQL error number.
One of ER_ codes from share/errmsg.txt. Set by set_error_status.
|
private |
List of conditions present in DA at handler activation.
|
private |
SQL RETURNED_SQLSTATE condition item.
This member is always NUL terminated.
|
private |
Save @error_count before pre-clearing the DA.
|
private |
Save @warning_count before pre-clearing the DA.
|
private |
Pointer to the Diagnostics Area below on the stack.
|
private |