Expand description
SQLSTATE error codes — Post-MVP credibility item.
Mirrors PostgreSQL’s errcodes.h 5-character SQLSTATE codes
so reddb errors carry the same standardized identifiers
drivers / client libs / monitoring tools already understand.
A SQLSTATE is a fixed 5-character ASCII string where the
first 2 characters identify a class and the next 3 identify
a specific condition within that class.
Examples:
08006connection_failure22012division_by_zero23505unique_violation42601syntax_error42P01undefined_tableXX000internal_error
§Why this matters
ODBC / JDBC / psycopg / pgx all switch on SQLSTATE for retry
logic, error categorization, and i18n. A reddb client that
sees 42P01 knows the table doesn’t exist regardless of the
human-readable message language. Without SQLSTATE, drivers
have to string-match error text — fragile across versions.
§Mapping to RedDBError
RedDBError -> SqlState is a one-line lookup. The reverse
direction (parse a 5-char code into a category) is also
available via SqlState::class() for filter UIs.
§Wiring
Phase post-MVP wiring adds a sqlstate() method on
RedDBError and threads the code through the wire protocol
ErrorResponse frame so HTTP / gRPC / stdio clients all
receive it.
Structs§
- SqlState
- 5-character SQLSTATE code wrapper. Stored as a fixed
[u8; 5]so it’sCopy, fits in a register, and can be compared with a single==.
Constants§
- ACTIVE_
SQL_ TRANSACTION - AMBIGUOUS_
COLUMN - CHECK_
VIOLATION - CONNECTION_
DOES_ NOT_ EXIST - CONNECTION_
EXCEPTION - CONNECTION_
FAILURE - DATATYPE_
MISMATCH - DATA_
CORRUPTED - DATA_
EXCEPTION - DEADLOCK_
DETECTED - DISK_
FULL - DIVISION_
BY_ ZERO - DUPLICATE_
COLUMN - DUPLICATE_
TABLE - FOREIGN_
KEY_ VIOLATION - INSUFFICIENT_
RESOURCES - INTEGRITY_
CONSTRAINT_ VIOLATION - INTERNAL_
ERROR - INVALID_
DATETIME_ FORMAT - INVALID_
PASSWORD - INVALID_
TEXT_ REPRESENTATION - INVALID_
TRANSACTION_ STATE - IO_
ERROR - NOT_
NULL_ VIOLATION - NO_
ACTIVE_ SQL_ TRANSACTION - NULL_
VALUE_ NOT_ ALLOWED_ DATA - NUMERIC_
VALUE_ OUT_ OF_ RANGE - OPERATOR_
INTERVENTION - OUT_
OF_ MEMORY - QUERY_
CANCELED - READ_
ONLY_ SQL_ TRANSACTION - SERIALIZATION_
FAILURE - SQLSERVER_
REJECTED_ ESTABLISHMENT - STRING_
DATA_ RIGHT_ TRUNCATION - SUCCESSFUL_
COMPLETION - SYNTAX_
ERROR - SYNTAX_
ERROR_ OR_ ACCESS_ RULE_ VIOLATION - SYSTEM_
ERROR - TOO_
MANY_ CONNECTIONS - TRANSACTION_
ROLLBACK - UNDEFINED_
COLUMN - UNDEFINED_
FUNCTION - UNDEFINED_
PARAMETER - UNDEFINED_
TABLE - UNIQUE_
VIOLATION - WRONG_
OBJECT_ TYPE
Functions§
- sqlstate_
for_ reddb_ error - Map a
RedDBErrorvariant to its SQLSTATE code. Used by the wire protocol’s error response frame so clients get the standardized identifier alongside the human message.