Skip to main content

Module sqlstate

Module sqlstate 

Source
Expand description

Standard PostgreSQL SQLSTATE code constants.

A single source of truth for every five-character SQLSTATE string used across the codebase. Grouping follows the PostgreSQL documentation appendix (Class 00–XX). All constants are &'static str so they compose directly with pgwire::error::ErrorInfo without any allocation.

Add new codes here when a new error path needs one; never inline a literal elsewhere — a typo in a SQLSTATE string is undetectable at compile time.

Structs§

AmbiguousSqlstate
A SQLSTATE string shared by more than one crate::error::ErrorCode meaning at the DdlError construction sites that actually use it.

Constants§

ACTIVE_SQL_TRANSACTION
active_sql_transaction: the statement cannot run inside a transaction block.
AMBIGUOUS_COLUMN
42702 — ambiguous_column: a bare column name that resolves against more than one relation in scope.
APPEND_ONLY_VIOLATION
23601 — NodeDB extension: append-only write rejected.
AUTH_TOKEN_EXPIRED
28000 — the session’s bearer token expired, and the client must re-authenticate. Its code is AUTH_EXPIRED. Ambiguous with the credential-failure meaning of 28000 — see AmbiguousSqlstate.
BACKUP_KEY_MISMATCH
28000 — NodeDB extension: the backup envelope did not decrypt under this server’s configured backup_encryption key. Aliased to invalid_authorization_specification, the same class used for any other presented-key mismatch. Ambiguous with the credential-failure meaning of 28000 — see AmbiguousSqlstate.
BACKUP_TENANT_MISMATCH
22023 — NodeDB extension: RESTORE’s target tenant does not match the tenant the envelope belongs to. Uses Class 22 “Data Exception” because the envelope is well-formed, just not for the requested tenant.
BALANCE_VIOLATION
23602 — NodeDB extension: balance constraint violated.
CANNOT_CLONE_MIRROR
0A000 — NodeDB extension: a mirror database cannot be cloned.
CANNOT_COERCE
42846 — cannot_coerce
CANNOT_CONNECT_NOW
57P03 — cannot_connect_now (collection is draining)
CANNOT_DROP_DEFAULT_DATABASE
0A000 — Cannot drop the built-in default database, which is immutable. Aliased to feature_not_supported per the PostgreSQL convention for unsupported DDL operations on reserved objects. Ambiguous with FEATURE_NOT_SUPPORTED and CANNOT_CLONE_MIRROR — see AmbiguousSqlstate.
CHECK_VIOLATION
23514 — check_violation
CLONE_DEPENDENCY
55006 — NodeDB extension: source database has active clone dependents.
CLONE_DEPTH_EXCEEDED
54011 — NodeDB extension: clone chain depth exceeds MAX_CLONE_DEPTH.
CLONE_PREDATES_QUERY_TIME
22023 — NodeDB extension: AS OF timestamp predates the clone’s creation point; the database did not exist at that time.
CLONE_WRITE_REQUIRES_MATERIALIZE
55006 — NodeDB extension: a write targeted a Shadowed/Materializing clone collection whose engine has no copy-on-write support.
CONFIGURATION_LIMIT_EXCEEDED
53400 — configuration_limit_exceeded (quota exceeded)
CONNECTION_FAILURE
08006 — connection_failure: a Control-to-Data-Plane dispatch could not reach the target core (bridge closed, core panic, timeout).
DATABASE_DROPPED
57P04 — database_dropped (not-leader redirect; client should retry elsewhere)
DATATYPE_MISMATCH
42804 — datatype_mismatch (a literal the declared column type cannot represent, such as a column DEFAULT refused at CREATE)
DATA_EXCEPTION
22000 — data_exception (a function received a value it cannot compute on: a vector of the wrong dimension, an argument of the wrong shape, a malformed JSONPath)
DATETIME_FIELD_OVERFLOW
22008 — datetime_field_overflow (an instant outside the range a timestamp or timestamptz holds)
DEPENDENT_OBJECTS_STILL_EXIST
2BP01 — dependent_objects_still_exist: a DROP names an object that other objects depend on.
DIVISION_BY_ZERO
22012 — division_by_zero (/ or % with a zero divisor — raised at runtime instead of evaluating to NULL)
DUPLICATE_OBJECT
42710 — duplicate_object: a named catalog object already exists.
FEATURE_NOT_SUPPORTED
0A000 — feature_not_supported
FOREIGN_KEY_VIOLATION
23503 — foreign_key_violation (dangling-edge rejection)
GENERATED_ALWAYS
428C9 — generated_always (a write names a generated column; its value is computed from other columns)
INSUFFICIENT_PRIVILEGE
42501 — insufficient_privilege
INTEGRITY_CONSTRAINT_VIOLATION
23000 — integrity_constraint_violation (generic)
INTERNAL_ERROR
XX000 — internal_error
INVALID_AUTHORIZATION
28000 — invalid_authorization_specification: no valid credentials. The default meaning, a credential failure. Its code is AUTHENTICATION_FAILED, the code INVALID_PASSWORD has too, so a client cannot tell a wrong password from an unknown user.
INVALID_CATALOG_NAME
3D000 — invalid_catalog_name (the selected database does not exist)
INVALID_DATETIME_FORMAT
22007 — invalid_datetime_format (text that does not parse as a timestamp or timestamptz)
INVALID_LIMIT_VALUE
2201W — invalid_limit_value (a LIMIT/OFFSET/FETCH bound that is negative, fractional, non-numeric, or wider than usize)
INVALID_PARAMETER_VALUE
22023 — invalid_parameter_value (a SET value the parameter’s own grammar refuses, e.g. SET statement_timeout = 'later')
INVALID_PASSWORD
28P01 — invalid_password: a credential failure. Same code as INVALID_AUTHORIZATION.
INVALID_TEXT_REPRESENTATION
22P02 — invalid_text_representation (stored text that does not parse as the number an operation reads, e.g. INCR on "abc")
IO_ERROR
58030 — io_error: a WAL append or filesystem operation failed.
LEGAL_HOLD_ACTIVE
23607 — NodeDB extension: legal hold blocks deletion.
LOCK_NOT_AVAILABLE
55P03 — lock_not_available (no cluster leader)
MOVE_TENANT_ALREADY_AT_TARGET
02000 — no_data: tenant is already present in the target database; the MOVE TENANT is a no-op (idempotent retry of a completed move). Ambiguous with the generic “no data found” use of 02000 — see AmbiguousSqlstate.
MOVE_TENANT_CUTOVER_FAILED
XX000 — internal error during cutover phase; source still holds data. Ambiguous with the generic internal-error use of XX000 — see AmbiguousSqlstate.
MOVE_TENANT_DRAIN_TIMEOUT
57014 — query_canceled: drain phase timed out; client should re-try after ensuring the tenant has no active connections on the source database. Ambiguous with the other meanings of QUERY_CANCELED — see AmbiguousSqlstate.
MOVE_TENANT_PREFLIGHT_FAILED
55P02 — lock_not_available: pre-flight check found schema incompatibility between the source and target databases; no state was mutated.
MOVE_TENANT_SNAPSHOT_FAILED
XX000 — internal error during snapshot phase; source left unchanged. Ambiguous with the generic internal-error use of XX000 — see AmbiguousSqlstate.
NOT_NULL_VIOLATION
23502 — not_null_violation
NO_DATA
02000 — no_data (document / row not found)
NUMERIC_VALUE_OUT_OF_RANGE
22003 — numeric_value_out_of_range
OBJECT_NOT_IN_PREREQUISITE_STATE
55000 — object_not_in_prerequisite_state (the object exists but the step this statement needs has not run, e.g. currval before nextval)
OUT_OF_MEMORY
53200 — out_of_memory
PERIOD_LOCKED
23603 — NodeDB extension: period lock; writes rejected.
PERIOD_LOCK_MISCONFIGURED
23609 — NodeDB extension: period-lock reference row has no configured status column; a misconfigured column name, not a locked period.
PROGRAM_LIMIT_EXCEEDED
54000 — program_limit_exceeded (generic over-cap)
PROTOCOL_VIOLATION
08P01 — protocol_violation: the protocol handshake failed.
QUERY_CANCELED
57014 — query_canceled: a deadline passed, or a user or statement cancelled the query. No meaning is the default, so a bare 57014 never classifies as the retriable deadline code — see AmbiguousSqlstate.
QUOTA_EXCEEDED
53400 — configuration_limit_exceeded: tenant or database has exhausted its configured resource budget (TENANT_QUOTA_EXCEEDED, DATABASE_QUOTA_EXCEEDED). Class 53 is preferred over 54 because the limit is a runtime configuration setting, not a hard-coded program limit.
QUOTA_OVERCOMMIT
53400 — configuration_limit_exceeded: sum of tenant/database quotas would exceed the configured global or parent ceiling (QUOTA_OVERCOMMIT). Alias for CONFIGURATION_LIMIT_EXCEEDED.
READ_ONLY_SQL_TRANSACTION
25006 — read_only_sql_transaction: a write targeted a read-only database, such as an unpromoted mirror.
RETENTION_VIOLATION
23606 — NodeDB extension: retention policy blocks deletion.
SERIALIZATION_FAILURE
40001 — serialization_failure (write conflict; client should retry)
SERVER_OVERLOAD
57P03 — cannot_connect_now: server is under global resource pressure and cannot accept new requests (SERVER_OVERLOAD). Using 57P03 rather than 53300 (too_many_connections) because the condition is transient and the server may accept requests again shortly — clients should retry after backoff.
SERVER_REJECTED_ESTABLISHMENT
08004 — sqlserver_rejected_establishment_of_sqlconnection: the server refused to establish a sync shape subscription.
STALE_READ_NOT_LEADER
55P03 — NodeDB extension: this node cannot satisfy the requested consistency level, because it is not the Raft leader for the data and cannot prove that it is.
STATEMENT_TOO_COMPLEX
54001 — statement_too_complex
STATE_TRANSITION_VIOLATION
23604 — NodeDB extension: state-transition constraint violated.
SUCCESS
00000 — successful_completion
SYNTAX_ERROR
42601 — syntax_error
TOO_MANY_CONNECTIONS
53300 — too_many_connections (closest match for rate-limit denial)
TRANSACTION_ROLLBACK
40000 — transaction_rollback (rolled back for a reason other than a serialization conflict; class 40 tells the client to retry)
TRANSITION_CHECK_VIOLATION
23605 — NodeDB extension: transition-check constraint violated.
TYPE_GUARD_VIOLATION
23608 — NodeDB extension: type-guard constraint violated.
UNDEFINED_COLUMN
42703 — undefined_column (a column reference that resolves against no relation in scope)
UNDEFINED_FUNCTION
42883 — undefined_function (no scalar/aggregate/window function registered under the called name)
UNDEFINED_OBJECT
42704 — undefined_object (a runtime parameter the server does not carry, e.g. SET nonsense = 1 or SHOW nonsense)
UNDEFINED_TABLE
42P01 — undefined_table (collection not found)
UNIQUE_VIOLATION
23505 — unique_violation
WARNING
01000 — warning (generic warning)
WRONG_OBJECT_TYPE
42809 — wrong_object_type (a statement the named object’s kind does not take, such as a write to a continuous aggregate)