|
KDBC
Unified C Database Connectivity — SQLite, PostgreSQL, MariaDB, Oracle, MSSQL
|
Functions | |
| const char * | kdbc_error (kdbc_conn *conn) |
| Get the last error message for a connection. | |
| const char * | kdbc_stmt_error (kdbc_stmt *stmt) |
| Get the last error message for a statement. | |
| const char * | kdbc_global_error (void) |
| Get the last global (connection-less) error message. | |
| const char * | kdbc_sqlstate (kdbc_conn *conn) |
| Get the SQLSTATE code for the last connection error. | |
| int | kdbc_errcode (kdbc_conn *conn) |
| Get the vendor-specific error code for the last connection error. | |
| const char * | kdbc_stmt_sqlstate (kdbc_stmt *stmt) |
| Get the SQLSTATE code for the last statement error. | |
| int | kdbc_stmt_errcode (kdbc_stmt *stmt) |
| Get the vendor-specific error code for the last statement error. | |
| const char * | kdbc_global_sqlstate (void) |
| Get the SQLSTATE code for the last connection-less (global) error. | |
| int | kdbc_global_errcode (void) |
| Get the vendor-specific error code for the last connection-less error. | |
| const char * | kdbc_result_error (kdbc_result *rs) |
| Get the last error message for a result set. | |
| const char * | kdbc_result_sqlstate (kdbc_result *rs) |
| Get the SQLSTATE code for the last result-set error. | |
| int | kdbc_result_errcode (kdbc_result *rs) |
| Get the vendor-specific error code for the last result-set error. | |
Retrieve error messages from connections, statements, or global context.
Each handle (kdbc_conn, kdbc_stmt) maintains its own error buffer (1024 bytes). The global error buffer is thread-local, used for errors that occur outside a connection context (e.g. driver not available, connection failure).
Returned pointers are valid until the next KDBC call on the same handle, or until the handle is closed. Returns "" (empty string) when no error has occurred.
| const char * kdbc_error | ( | kdbc_conn * | conn | ) |
Get the last error message for a connection.
| conn | The connection to query. |
| const char * kdbc_stmt_error | ( | kdbc_stmt * | stmt | ) |
Get the last error message for a statement.
| stmt | The statement to query. |
| const char * kdbc_global_error | ( | void | ) |
Get the last global (connection-less) error message.
Used for errors that occur before a connection exists, such as driver-not-available or connection failure. Thread-local — safe to call from any thread.
| const char * kdbc_sqlstate | ( | kdbc_conn * | conn | ) |
Get the SQLSTATE code for the last connection error.
SQLSTATE is the 5-character standard code defined by SQL-92 and reported by drivers that support it (PostgreSQL, MariaDB/MySQL, Oracle). Drivers that do not surface SQLSTATE (SQLite, MS SQL Server via db-lib) leave the field empty. The pointer is owned by the connection and remains valid until the next KDBC call on it.
| conn | The connection to query. |
| int kdbc_errcode | ( | kdbc_conn * | conn | ) |
Get the vendor-specific error code for the last connection error.
The semantics depend on the driver: SQLite returns the extended result code, MariaDB/MySQL returns mysql_errno, Oracle returns the ORA number, MS SQL Server returns the message number. PostgreSQL and other drivers that only carry SQLSTATE return 0.
| conn | The connection to query. |
| const char * kdbc_stmt_sqlstate | ( | kdbc_stmt * | stmt | ) |
Get the SQLSTATE code for the last statement error.
| stmt | The statement to query. |
| int kdbc_stmt_errcode | ( | kdbc_stmt * | stmt | ) |
Get the vendor-specific error code for the last statement error.
| stmt | The statement to query. |
| const char * kdbc_global_sqlstate | ( | void | ) |
Get the SQLSTATE code for the last connection-less (global) error.
Thread-local — safe to call from any thread.
| int kdbc_global_errcode | ( | void | ) |
Get the vendor-specific error code for the last connection-less error.
Thread-local — safe to call from any thread.
| const char * kdbc_result_error | ( | kdbc_result * | rs | ) |
Get the last error message for a result set.
| rs | The result set to query. |
| const char * kdbc_result_sqlstate | ( | kdbc_result * | rs | ) |
Get the SQLSTATE code for the last result-set error.
| rs | The result set to query. |
| int kdbc_result_errcode | ( | kdbc_result * | rs | ) |
Get the vendor-specific error code for the last result-set error.
| rs | The result set to query. |