![]() |
MySQL 9.1.0
Source Code Documentation
|
A service that provides the API to get the errors and warnings including fetching the warning, getting error/warning number, error/warning level, error/warning message, SQL state. More...
#include <mysql_statement_service.h>
A service that provides the API to get the errors and warnings including fetching the warning, getting error/warning number, error/warning level, error/warning message, SQL state.
In addition, for INSERT/UPDATE/DELETE, the service provides the API to get the number of affected rows and last insert ID.
Usage example: For INSERT/UPDATE/DELETE/... statements, to get the number of affected rows and last insert id.
uint64_t num_affected_rows; SERVICE_PLACEHOLDER(mysql_stmt_diagnostics)->affected_rows(statement, &num_affected_rows) auto last_insert_id = uint64_t{}; SERVICE_PLACEHOLDER(mysql_stmt_diagnostics)->insert_id(statement, &last_insert_id)
To get the diagnostics information auto error_number = uint64_t{}; SERVICE_PLACEHOLDER(mysql_stmt_diagnostics)->error_id(statement, &error_number); char const *sql_errmsg = nullptr; SERVICE_PLACEHOLDER(mysql_stmt_diagnostics)->error(statement, &sql_errmsg); char const *sql_state = nullptr; SERVICE_PLACEHOLDER(mysql_stmt_diagnostics)->get_sql_state(statement, &sql_state); auto warning_count = uint32_t{}; SERVICE_PLACEHOLDER(mysql_stmt_diagnostics)->num_warnings(statement, &warning_count);
for(size_t warn_index = 0; warn_index < warning_count; warn_index++) { my_h_warning warning = nullptr; SERVICE_PLACEHOLDER(mysql_stmt_diagnostics)->get_warning(statement, warn_index, &warning); auto level = uint32_t{}; SERVICE_PLACEHOLDER(mysql_stmt_diagnostics)->warning_level(warning, &level);
Similarly for code and message }
mysql_service_status_t(* s_mysql_mysql_stmt_diagnostics::affected_rows) (my_h_statement statement, uint64_t *num_rows) |
Get the number of affected rows for DDL e.g.
UPDATE/DELETE/INSERT statements.
[in] | statement | A handle to the statement |
[out] | num_rows | Number of rows affected |
false | success |
true | failure |
mysql_service_status_t(* s_mysql_mysql_stmt_diagnostics::error) (my_h_statement statement, mysql_cstring_with_length *error_message) |
Get the error message of the last error.
[in] | statement | The statement handle |
[out] | error_message | The error message |
false | success |
true | failure |
mysql_service_status_t(* s_mysql_mysql_stmt_diagnostics::error_number) (my_h_statement statement, uint64_t *error_number) |
Get the error number of the last error.
[in] | statement | The statement handle |
[out] | error_number | The error number |
false | success |
true | failure |
mysql_service_status_t(* s_mysql_mysql_stmt_diagnostics::get_warning) (my_h_statement statement, uint32_t warning_index, my_h_warning *warning) |
Get the warning at the index.
[in] | statement | The statement handle |
[in] | warning_index | 0-based index of the warning |
[out] | warning | The warning |
false | success |
true | failure |
mysql_service_status_t(* s_mysql_mysql_stmt_diagnostics::insert_id) (my_h_statement statement, uint64_t *last_id) |
Get the last insert id which is the ID generated for an AUTO_INCREMENT column.
[in] | statement | A handle to the statement |
[out] | last_id | The last insert id |
false | success |
true | failure |
mysql_service_status_t(* s_mysql_mysql_stmt_diagnostics::num_warnings) (my_h_statement statement, uint32_t *count) |
Get the number of warnings of the recently invoked statement.
[in] | statement | The statement handle |
[out] | count | The number of warnings |
false | success |
true | failure |
mysql_service_status_t(* s_mysql_mysql_stmt_diagnostics::sqlstate) (my_h_statement statement, mysql_cstring_with_length *sqlstate) |
Get SQLSTATE error code for the last error similar to https://dev.mysql.com/doc/c-api/8.0/en/mysql-stmt-sqlstate.html.
[in] | statement | The statement handle |
[out] | sqlstate | Stores the SQLSTATE status of the most recently executed SQL stmt. |
false | success |
true | failure |
mysql_service_status_t(* s_mysql_mysql_stmt_diagnostics::warning_code) (my_h_warning warning, uint32_t *code) |
Get the code of the warning.
[in] | warning | The warning |
[out] | code | The code |
false | success |
true | failure |
mysql_service_status_t(* s_mysql_mysql_stmt_diagnostics::warning_level) (my_h_warning warning, uint32_t *level) |
Get the severity level of the warning.
[in] | warning | The warning |
[out] | level | The level |
false | success |
true | failure |
mysql_service_status_t(* s_mysql_mysql_stmt_diagnostics::warning_message) (my_h_warning warning, mysql_cstring_with_length *error_message) |
Get the message of the warning.
[in] | warning | The warning |
[out] | code | The message |
false | success |
true | failure |