22005 — error_in_assignment
22005
At a glance
22005 is error_in_assignment. The fixed PL/pgSQL path reports assignment to a variable declared CONSTANT; ECPG and other assignment layers may have separate boundaries.
| Field | Value |
|---|---|
| SQLSTATE | 22005 |
| Condition | error_in_assignment |
| Status | active |
| Known present by | 7.4 |
| Locked snapshots | 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3 |
| Macros | ERRCODE_ERROR_IN_ASSIGNMENT |
| Aliases | — |
Meaning
22005 is error_in_assignment. The fixed PL/pgSQL path reports assignment to a variable declared CONSTANT; ECPG and other assignment layers may have separate boundaries.
exec_check_assignable applies this guard to PL/pgSQL variables, promise variables, and records whose isconst flag is set. Record fields delegate the check to their parent record, while row datums are assignable; this is why the routine context and the named datum matter.
Messages
The confirmed branch raises ERROR with primary variable "%s" is declared CONSTANT. It has no fixed DETAIL or HINT. This page is source-only; no natural runtime observation is claimed.
Diagnosis
Read the named variable and routine context. The confirmed path is a PL/pgSQL assignment contract, not a general type conversion or target-column error.
Response
Remove the assignment, change the declaration when mutability is intended, or assign to a separate variable. Correct the routine before rerunning its business operation. An uncaught ERROR in an explicit transaction leaves that transaction failed; roll it back or use a savepoint established before the call. A PL/pgSQL EXCEPTION block can contain the failure in its subtransaction when the routine is deliberately written to handle it; this page has no runtime case proving a particular handler.
Versions
The locked catalogue records this condition from 7.4 in the listed formal snapshots and 19beta3; fixed source coverage is PostgreSQL 18.6.
Related
Sources
See the fixed source links and scope limits in the structured evidence record.