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§
- Ambiguous
Sqlstate - A SQLSTATE string shared by more than one
crate::error::ErrorCodemeaning at theDdlErrorconstruction 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 isAUTH_EXPIRED. Ambiguous with the credential-failure meaning of28000— seeAmbiguousSqlstate.- BACKUP_
KEY_ MISMATCH 28000— NodeDB extension: the backup envelope did not decrypt under this server’s configuredbackup_encryptionkey. Aliased toinvalid_authorization_specification, the same class used for any other presented-key mismatch. Ambiguous with the credential-failure meaning of28000— seeAmbiguousSqlstate.- 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-indefaultdatabase, which is immutable. Aliased tofeature_not_supportedper the PostgreSQL convention for unsupported DDL operations on reserved objects. Ambiguous withFEATURE_NOT_SUPPORTEDandCANNOT_CLONE_MIRROR— seeAmbiguousSqlstate.- 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 exceedsMAX_CLONE_DEPTH.- CLONE_
PREDATES_ QUERY_ TIME 22023— NodeDB extension:AS OFtimestamp predates the clone’s creation point; the database did not exist at that time.- CLONE_
WRITE_ REQUIRES_ MATERIALIZE 55006— NodeDB extension: a write targeted aShadowed/Materializingclone 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 columnDEFAULTrefused atCREATE)- 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 atimestamportimestamptzholds)- 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 toNULL)- 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 isAUTHENTICATION_FAILED, the codeINVALID_PASSWORDhas 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 atimestamportimestamptz)- INVALID_
LIMIT_ VALUE 2201W—invalid_limit_value(a LIMIT/OFFSET/FETCH bound that is negative, fractional, non-numeric, or wider thanusize)- INVALID_
PARAMETER_ VALUE 22023—invalid_parameter_value(aSETvalue the parameter’s own grammar refuses, e.g.SET statement_timeout = 'later')- INVALID_
PASSWORD 28P01—invalid_password: a credential failure. Same code asINVALID_AUTHORIZATION.- INVALID_
TEXT_ REPRESENTATION 22P02—invalid_text_representation(stored text that does not parse as the number an operation reads, e.g.INCRon"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; theMOVE TENANTis a no-op (idempotent retry of a completed move). Ambiguous with the generic “no data found” use of02000— seeAmbiguousSqlstate.- MOVE_
TENANT_ CUTOVER_ FAILED XX000— internal error during cutover phase; source still holds data. Ambiguous with the generic internal-error use ofXX000— seeAmbiguousSqlstate.- 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 ofQUERY_CANCELED— seeAmbiguousSqlstate.- 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 ofXX000— seeAmbiguousSqlstate.- 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.currvalbeforenextval)- 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 bare57014never classifies as the retriable deadline code — seeAmbiguousSqlstate.- 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 forCONFIGURATION_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). Using57P03rather than53300(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 = 1orSHOW 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)