22005
Read PG 18 manual ↗error_in_assignment
- SQLSTATE
- 22005
- Condition name
- error_in_assignment
- Class
- Data Exception
- Source macro
- ERRCODE_ERROR_IN_ASSIGNMENT
- Evidence
- Source path confirmed
English SQLSTATE atlas: authored explanations and source/runtime evidence are separate from the manual definitions. View source ↗
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.
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.
Sources
See the fixed source links and scope limits in the structured evidence record.
Source evidence
Evidence belongs to the frozen source and runtime versions listed here. It is not a runtime verification of the selected manual version.
PL/pgSQL assignment checking rejects writes to a variable marked CONSTANT and reports the variable name.
Method: Read exec_check_assignable and its complete CONSTANT branch.
Limits: This does not classify every type conversion or target-column assignment error.
The locked catalogue records 22005 from 7.4 without proving an exact implementation introduction date.
Method: Use catalogue boundary.
- src/backend/utils/errcodes.txt · REL_18_6 ·
724edf9bde9d356724ad384a2e196edc3c9f80f7 raw/calls/REL_18_6.jsonl· ·- src/pl/plpgsql/src/pl_exec.c · REL_18_6 ·
724edf9bde9d356724ad384a2e196edc3c9f80f7
Message templates
ERROR · message.constant
Primary
variable "%s" is declared CONSTANT
Reproduction & repair cases
No reproduction case is attached to this condition.
Recorded runtime evidence
No runtime observation is attached to this entry.
Definition snapshot: english-manuals:8c8a30e1e6816c0e3ca82e8393f… · English manual source