Mstdlib-1.24.0
|
Functions | |
const char * | M_sql_error_string (M_sql_error_t err) |
M_bool | M_sql_error_is_error (M_sql_error_t err) |
M_bool | M_sql_error_is_disconnect (M_sql_error_t err) |
M_bool | M_sql_error_is_rollback (M_sql_error_t err) |
M_bool | M_sql_error_is_fatal (M_sql_error_t err) |
SQL Error handling
enum M_sql_error_t |
Possible error conditions
Enumerator | |
---|---|
M_SQL_ERROR_SUCCESS | No error, success. If returned by M_sql_stmt_fetch(), there are guaranteed to not be any rows in the result set. However, for an M_sql_stmt_execute() or M_sql_trans_execute() if M_sql_stmt_set_max_fetch_rows() was not set, there may be rows available. |
M_SQL_ERROR_SUCCESS_ROW | No error, success, rows may be available to be fetched |
M_SQL_ERROR_CONN_NODRIVER | Driver not found for specified driver name. |
M_SQL_ERROR_CONN_DRIVERLOAD | Failed to dynamically load driver module. |
M_SQL_ERROR_CONN_DRIVERVER | Driver version invalid |
M_SQL_ERROR_CONN_PARAMS | Connection string parameter validation failed |
M_SQL_ERROR_CONN_FAILED | Failed to establish connection to server. |
M_SQL_ERROR_CONN_BADAUTH | Failed to authenticate against server. |
M_SQL_ERROR_CONN_LOST | Connection to server has been lost (remote disconnect). |
M_SQL_ERROR_PREPARE_INVALID | Invalid query format |
M_SQL_ERROR_PREPARE_STRNOTBOUND | A string was detected in the query that was not bound |
M_SQL_ERROR_PREPARE_NOMULITQUERY | Multiple requests in a single query are not allowed |
M_SQL_ERROR_QUERY_NOTPREPARED | Can't execute query as statement hasn't been prepared |
M_SQL_ERROR_QUERY_WRONGNUMPARAMS | Wrong number of bound parameters provided for query |
M_SQL_ERROR_QUERY_PREPARE | DB Driver failed to prepare the query for execution |
M_SQL_ERROR_QUERY_DEADLOCK | Deadlock (must rollback), cannot continue. |
M_SQL_ERROR_QUERY_CONSTRAINT | Constraint failed (e.g. Unique key or primary key conflict) |
M_SQL_ERROR_QUERY_FAILURE | Failure (uncategorized) |
M_SQL_ERROR_INUSE | Resource in use, invalid action |
M_SQL_ERROR_INVALID_USE | Invalid use |
M_SQL_ERROR_INVALID_TYPE | Invalid Data Type for conversion |
M_SQL_ERROR_USER_SUCCESS | Return code a User can generate in M_sql_trans_process() to Indicate the operation is complete and the system can commit any pending data. This is equivalent to M_SQL_ERROR_SUCCESS but can be used in its place if a user needs to have the ability to differentiate how M_sql_trans_process() returned success. |
M_SQL_ERROR_USER_BYPASS | Return code a User can generate in M_sql_trans_process() to indicate the operation should be bypassed. This can be used to differentiate a traditional tristate error message. Otherwise this is classified as success. |
M_SQL_ERROR_USER_RETRY | Return code a User can generate in M_sql_trans_process() to request the system to rollback and retry the entire sequence of events. This is equivalent to M_SQL_ERROR_QUERY_DEADLOCK but more accurately indicates the failure was due to user-logic rather than a condition triggered internally to the SQL system |
M_SQL_ERROR_USER_FAILURE | Return code a User can generate in M_sql_trans_process() to request the system to rollback and return the error to the caller. This is equivalent to M_SQL_ERROR_QUERY_FAILURE but more accurately indicates the failure was due to user-logic rather than a condition triggered internally to the SQL system |
M_SQL_ERROR_UNSET | Error message not set. Internal use only. |
enum M_sql_data_type_t |
Possible SQL data types
const char * M_sql_error_string | ( | M_sql_error_t | err | ) |
Retrieve generic error string associated with error code.
Often the error message returned by the calling function or M_sql_stmt_get_error_string() is more useful for human display purposes.
[in] | err | Error to evaluate |
M_bool M_sql_error_is_error | ( | M_sql_error_t | err | ) |
Returns if error code is a failure or not.
Currently this returns true if the error condition is any error other than M_SQL_ERROR_SUCCESS or M_SQL_ERROR_SUCCESS_ROW.
[in] | err | Error to evaluate |
M_bool M_sql_error_is_disconnect | ( | M_sql_error_t | err | ) |
Returns if the error code is due to a fatal communications error. If this occurs, the connection will be automatically destroyed and next use will try to establish a new connection
[in] | err | Error to evaluate. |
M_bool M_sql_error_is_rollback | ( | M_sql_error_t | err | ) |
Returns if the error code represents a rollback condition.
There may be multiple types of failures that are rollback conditions such as unexpected disconnects from the database, deadlocks, and consistency failures. This function checks for all known conditions where a rollback should be performed.
[in] | err | Error to evaluate. |
M_bool M_sql_error_is_fatal | ( | M_sql_error_t | err | ) |
Returns if the error code represents a fatal error returned from the server that is unlikely to succeed if simply re-attempted. Often this is the result of a poorly formed query that can't be parsed or prepared.
Currently this is equivelent to:
[in] | err | Error to evaluate. |