select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

SQLSTATE / CLASS 42 · SYNTAX ERROR OR ACCESS RULE VIOLATION

generated_always

SQLSTATE
428C9
Condition name
generated_always
Class
Syntax Error or Access Rule Violation
Source macro
ERRCODE_GENERATED_ALWAYS
Evidence
Source path confirmed
Analysis & operational context

English SQLSTATE atlas: authored explanations and source/runtime evidence are separate from the manual definitions. View source ↗

<h1>428C9 — Generated-always column assignment</h1>

At a glance

428C9 (generated_always) is a rewrite-stage ERROR when an INSERT or UPDATE supplies a value where PostgreSQL must generate it or receive DEFAULT. Identity columns and generated columns follow different assignment rules, so the operation and column metadata matter.

Meaning

The rewriter computes apply_default for an omitted INSERT target or an explicit DEFAULT. For an identity column marked GENERATED ALWAYS, a non-default INSERT is rejected unless OVERRIDING SYSTEM VALUE is present; OVERRIDING USER VALUE instead forces the default. An identity column marked BY DEFAULT accepts a supplied value, but OVERRIDING USER VALUE still forces generation. Generated columns take only DEFAULT, regardless of an OVERRIDING clause. The INSERT branches identify the column in DETAIL, and the identity-always branch adds HINT Use OVERRIDING SYSTEM VALUE to override.

For UPDATE, the guard covers identity GENERATED ALWAYS and every generated column when a non-default target entry is present; UPDATE has no OVERRIDING escape. After the guard, a virtual generated column gets a null target entry and a stored generated column is filled by the executor. This storage behavior is part of the 18.6 source path and does not turn the catalogue's 10.0 SQLSTATE lower bound into a claim that every generated-column feature existed in 10.0.

Diagnosis

Inspect pg_attribute.attidentity (a for ALWAYS, d for BY DEFAULT) and attgenerated (s for stored, v for virtual), then record whether the command is INSERT or UPDATE and whether the target entry is omitted, DEFAULT, or a value. For an INSERT from VALUES, confirm whether the offending row item is actually DEFAULT; the rewriter has a separate all-default check. Read the primary, DETAIL, and HINT together: identity-always and generated-column INSERTs share a primary template but have different DETAIL/HINT contracts.

Response

For identity GENERATED ALWAYS, omit the value, use DEFAULT, or use OVERRIDING SYSTEM VALUE only when the application deliberately owns the identity value. For identity BY DEFAULT, leave the value in place when that is the contract; use OVERRIDING USER VALUE when the server must generate it. Remove assignments to generated columns and do not try to bypass the guard with a cast. If the ERROR occurred inside an explicit transaction, roll back to a suitable savepoint or roll back the transaction before issuing the corrected statement; this page has no runtime observation of that recovery.

Messages

The selected 18.6 groups are explicit ERRORs:

Operation Primary DETAIL HINT
identity GENERATED ALWAYS INSERT cannot insert a non-DEFAULT value into column "%s" Column "%s" is an identity column defined as GENERATED ALWAYS. Use OVERRIDING SYSTEM VALUE to override.
generated-column INSERT cannot insert a non-DEFAULT value into column "%s" Column "%s" is a generated column. none
identity GENERATED ALWAYS UPDATE column "%s" can only be updated to DEFAULT Column "%s" is an identity column defined as GENERATED ALWAYS. none
generated-column UPDATE column "%s" can only be updated to DEFAULT Column "%s" is a generated column. none

The fixed source also distinguishes virtual generated storage (null target entry) from stored generated storage (executor fill). Each %s is dynamic; no concrete placeholder value or runtime result is claimed.

Versions

The catalogue records the condition by 10.0 and locks snapshots through 18.6 and 19beta3. That is a definition lower bound, not a claim that identity, stored-generated, and virtual-generated features all share that introduction point. The selected mechanism is PostgreSQL 18.6 source; runtime was not run.

Sources

  • src.errcodes.428C9.18.6src/backend/utils/errcodes.txt line 355, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba (source).

  • src.call.428C9.353c4cc772b5ae9adad09c67src/backend/rewrite/rewriteHandler.c lines 942-948, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 5a34bf31f424abbf46cd926da1fefcd9360c4d527a87d8a0ac9f653d67c2206a (source).

  • src.call.428C9.47aaa60ecb1566d462ffaa86src/backend/rewrite/rewriteHandler.c lines 981-986, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 5a34bf31f424abbf46cd926da1fefcd9360c4d527a87d8a0ac9f653d67c2206a (source).
  • src.call.428C9.8585d423db2446a6222cbf57src/backend/rewrite/rewriteHandler.c lines 1008-1013, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 5a34bf31f424abbf46cd926da1fefcd9360c4d527a87d8a0ac9f653d67c2206a (source).
  • src.call.428C9.generated-updatesrc/backend/rewrite/rewriteHandler.c lines 1015-1030, fixed at 724edf9bde9d356724ad384a2e196edc3c9f80f7; SHA-256 5a34bf31f424abbf46cd926da1fefcd9360c4d527a87d8a0ac9f653d67c2206a (source).
  • src.calls.REL_18_6.428C9 — resolved core call groups; SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf.
  • authored evidence — source claims, message roles, and runtime boundary.

Source evidence

Evidence belongs to the frozen source and runtime versions listed here. It is not a runtime verification of the selected manual version.

428C9 is the generated_always condition in Class 42.

Method: Read fixed REL_18_6 errcodes.txt and locked facts.

Limits: Identity does not enumerate all source branches or client failures.

src.errcodes.428C9.18.6

The fixed rewrite branches compute apply_default for omitted INSERT targets and DEFAULT nodes. GENERATED ALWAYS identity INSERTs reject non-default values unless OVERRIDING SYSTEM VALUE is present; OVERRIDING USER VALUE forces the default, while BY DEFAULT identity accepts a supplied value unless USER VALUE is requested. Generated columns accept only DEFAULT. UPDATE guards reject non-default assignments to GENERATED ALWAYS identity and generated columns; virtual generated columns receive a null target entry and stored generated columns are filled by the executor.

Method: Read complete resolved REL_18_6 report groups and message roles.

Limits: Representative confirmed core paths only; not exhaustive historical or extension coverage.

src.call.428C9.353c4cc772b5ae9adad09c67 src.call.428C9.47aaa60ecb1566d462ffaa86 src.call.428C9.8585d423db2446a6222cbf57 src.call.428C9.generated-update

The catalogue records the condition by 10.0 and locks snapshots through 18.6 and 19beta3; this is a definition lower bound, not a shared introduction point for identity, stored-generated, and virtual-generated features. The selected mechanism is fixed 18.6 source and runtime was not run.

Method: Read locked catalogue facts and definition snapshots.

Limits: First observed release is a lower bound, not precise behavioral introduction.

src.errcodes.428C9.18.6

Message templates

explicit ERROR · message.variant-1

Primary

cannot insert a non-DEFAULT value into column "%s"

Detail

Column "%s" is an identity column defined as GENERATED ALWAYS.

Hint

Use OVERRIDING SYSTEM VALUE to override.

Primary

Column "%s" is an identity column defined as GENERATED ALWAYS.

Primary

Use OVERRIDING SYSTEM VALUE to override.

Placeholders remain dynamic source fields; no concrete runtime value is claimed.

explicit ERROR · message.variant-2

Primary

cannot insert a non-DEFAULT value into column "%s"

Detail

Column "%s" is a generated column.

Primary

Column "%s" is a generated column.

Placeholders remain dynamic source fields; no concrete runtime value is claimed.

explicit ERROR · message.variant-3

Primary

column "%s" can only be updated to DEFAULT

Detail

Column "%s" is an identity column defined as GENERATED ALWAYS.

Primary

Column "%s" is an identity column defined as GENERATED ALWAYS.

Placeholders remain dynamic source fields; no concrete runtime value is claimed.

explicit ERROR · message.variant-4

Primary

column "%s" can only be updated to DEFAULT

Detail

Column "%s" is a generated column.

Primary

Column "%s" is a generated column.

Placeholders remain dynamic source fields; no concrete runtime value is claimed.

Reproduction & repair cases

No reproduction case is attached to this condition.

Recorded runtime evidence

No runtime observation is attached to this entry.

Version history 1
  1. PG 9.6 → 10added

Definition snapshot: english-manuals:b4e17794c3ac437aa54ffc5447f… · English manual source