MySQL 8.4.1
Source Code Documentation
s_mysql_mysql_stmt_diagnostics Struct Reference

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>

Public Attributes

mysql_service_status_t(* affected_rows )(my_h_statement statement, uint64_t *num_rows)
 Get the number of affected rows for DDL e.g. More...
 
mysql_service_status_t(* 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. More...
 
mysql_service_status_t(* error_number )(my_h_statement statement, uint64_t *error_number)
 Get the error number of the last error. More...
 
mysql_service_status_t(* error )(my_h_statement statement, mysql_cstring_with_length *error_message)
 Get the error message of the last error. More...
 
mysql_service_status_t(* 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. More...
 
mysql_service_status_t(* num_warnings )(my_h_statement statement, uint32_t *count)
 Get the number of warnings of the recently invoked statement. More...
 
mysql_service_status_t(* get_warning )(my_h_statement statement, uint32_t warning_index, my_h_warning *warning)
 Get the warning at the index. More...
 
mysql_service_status_t(* warning_level )(my_h_warning warning, uint32_t *level)
 Get the severity level of the warning. More...
 
mysql_service_status_t(* warning_code )(my_h_warning warning, uint32_t *code)
 Get the code of the warning. More...
 
mysql_service_status_t(* warning_message )(my_h_warning warning, mysql_cstring_with_length *error_message)
 Get the message of the warning. More...
 

Detailed Description

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 }

Member Data Documentation

◆ affected_rows

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.

Parameters
[in]statementA handle to the statement
[out]num_rowsNumber of rows affected
Returns
Status of the performed operation
Return values
falsesuccess
truefailure

◆ error

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.

Parameters
[in]statementThe statement handle
[out]error_messageThe error message
Returns
Status of the performed operation
Return values
falsesuccess
truefailure

◆ error_number

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.

Parameters
[in]statementThe statement handle
[out]error_numberThe error number
Returns
Status of the performed operation
Return values
falsesuccess
truefailure

◆ get_warning

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.

Parameters
[in]statementThe statement handle
[in]warning_index0-based index of the warning
[out]warningThe warning
Returns
Status of the performed operation
Return values
falsesuccess
truefailure

◆ insert_id

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.

Parameters
[in]statementA handle to the statement
[out]last_idThe last insert id
Returns
Status of the performed operation
Return values
falsesuccess
truefailure

◆ num_warnings

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.

Parameters
[in]statementThe statement handle
[out]countThe number of warnings
Returns
Status of the performed operation
Return values
falsesuccess
truefailure

◆ sqlstate

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.

Parameters
[in]statementThe statement handle
[out]sqlstateStores the SQLSTATE status of the most recently executed SQL stmt.
Returns
Status of the performed operation
Return values
falsesuccess
truefailure

◆ warning_code

mysql_service_status_t(* s_mysql_mysql_stmt_diagnostics::warning_code) (my_h_warning warning, uint32_t *code)

Get the code of the warning.

Parameters
[in]warningThe warning
[out]codeThe code
Returns
Status of the performed operation
Return values
falsesuccess
truefailure

◆ warning_level

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.

Parameters
[in]warningThe warning
[out]levelThe level
Returns
Status of the performed operation
Return values
falsesuccess
truefailure

◆ warning_message

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.

Parameters
[in]warningThe warning
[out]codeThe message
Returns
Status of the performed operation
Return values
falsesuccess
truefailure

The documentation for this struct was generated from the following file: