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

invalid_column_reference

SQLSTATE
42P10
Condition name
invalid_column_reference
Class
Syntax Error or Access Rule Violation
Source macro
ERRCODE_INVALID_COLUMN_REFERENCE
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>42P10 — Invalid column reference</h1>

At a glance

42P10 (invalid_column_reference) Column references can be rejected by the operation that consumes them.

Meaning

Several consumers use 42P10 for different column-reference contracts. In the selected 18.6 paths, cookConstraint permits only the table that owns a CHECK constraint, CopyGetAttnums rejects a generated column named in an explicit COPY list (the default list skips generated columns), and ON CONFLICT inference reports this code when no suitable arbiter index matches. The last path is an inference failure, not a generic missing-column error.

Diagnosis

Read the complete primary message and DETAIL, then identify the statement phase: CHECK constraint ownership, an explicit COPY column list, or ON CONFLICT arbiter inference. For COPY, distinguish a user-supplied list from the default list. For ON CONFLICT, inspect the action and the candidate index's columns or expressions, predicate, collation, and operator class; DO UPDATE needs a matching unique arbiter, while an exclusion constraint is not a general substitute for that action. Do not diagnose this as a missing column without the phase-specific message.

Response

Repair the specific contract: define the CHECK on its owning table, omit generated columns from an explicit COPY list, or align ON CONFLICT with an existing suitable unique index/constraint and its inference details. For DO NOTHING, verify the action-specific arbiter rules before considering an exclusion constraint. Do not create an arbitrary constraint as a generic repair. If this ERROR occurs inside an explicit transaction, ROLLBACK before the next command or ROLLBACK TO a savepoint created before the statement, then retry only after checking the catalog.

Messages

Representative source messages include: message: only table "%s" can be referenced in check constraint; message: column "%s" is a generated column; DETAIL: Generated columns cannot be used in COPY.; message: there is no unique or exclusion constraint matching the ON CONFLICT specification. Placeholders are filled by the actual object, column, or parameter.

Versions

The locked catalogue shows this condition by PostgreSQL 7.4; behavior here is fixed to PostgreSQL 18.6 source. Catalogue presence is a range boundary, not proof that every message or feature began in that release.

Sources

Source messages, line anchors, and evidence limits are recorded in authored evidence.

Source evidence

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

42P10 is the invalid_column_reference 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.42P10.18.6

Selected 18.6 paths use 42P10 for different column-reference contracts: cookConstraint permits only the table owning a CHECK constraint, CopyGetAttnums rejects a generated column named in an explicit COPY list while the default list skips generated columns, and ON CONFLICT inference reports this code when no suitable arbiter index matches. The ON CONFLICT message is an inference failure, not a generic missing-column error.

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

Limits: Representative confirmed core paths only; ON CONFLICT action-specific arbiter rules and historical/extension coverage are not exhaustive.

src.call.42P10.2fe5eef548819ba1cf9ab7c2 src.call.42P10.4cc3c771f6b98871572af1b5 src.call.42P10.9fb7b007472c34d677de2888

Locked catalogue snapshots show this condition by PostgreSQL 7.4; source behavior here is fixed at PostgreSQL 18.6.

Method: Read locked catalogue facts and definition snapshot.

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

src.errcodes.42P10.18.6

Message templates

ERROR · message.variant-1

Primary

only table "%s" can be referenced in check constraint

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

ERROR · message.variant-2

Primary

column "%s" is a generated column

Detail

Generated columns cannot be used in COPY.

Primary

Generated columns cannot be used in COPY.

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

ERROR · message.variant-3

Primary

there is no unique or exclusion constraint matching the ON CONFLICT specification

The primary is source-exact; DO UPDATE needs a matching unique arbiter, while an exclusion constraint is not a general substitute for that action. 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.

Definition snapshot: english-manuals:80044444ad6f8f10f650f0fe59d… · English manual source