42P10 — Invalid column reference
42P10 (invalid_column_reference) Column references can be rejected by the operation that consumes them.
English manual coverage begins with PostgreSQL 8.1. Source history and runtime observations have their own recorded version boundaries.
Reading PG 18·Select a recorded version
- aliases
- Unknown
- class name
- Syntax Error or Access Rule Violation
- condition name
- invalid_column_reference
- lang
- en
- sqlstate
- 42P10
Definition PG 18
42P10 — Invalid column reference
At a glance {#at-a-glance}
42P10 (invalid_column_reference) Column references can be rejected by the operation that consumes them.
Meaning {#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 {#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 {#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 {#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 {#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.
Related {#related}
Sources {#sources}
Source messages, line anchors, and evidence limits are recorded in authored evidence.
src/backend/catalog/heap.c:3465-3468(fixed source)src/backend/commands/copy.c:1026-1030(fixed source)src/backend/optimizer/util/plancat.c:958-960(fixed source)
Compare versions
SQLSTATE evidence and recorded runtime versions
claims · identity.class-and-condition
{
"claim_id": "identity.class-and-condition",
"limits": "Identity does not enumerate all source branches or client failures.",
"method": "Read fixed REL_18_6 errcodes.txt and locked facts.",
"position": 0,
"runtime": [],
"sources": [
"src.errcodes.42P10.18.6"
],
"statement": "42P10 is the invalid_column_reference condition in Class 42."
}claims · mechanism.selected-source-path
{
"claim_id": "mechanism.selected-source-path",
"limits": "Representative confirmed core paths only; ON CONFLICT action-specific arbiter rules and historical/extension coverage are not exhaustive.",
"method": "Read selected resolved REL_18_6 report groups and message roles.",
"position": 1,
"runtime": [],
"sources": [
"src.call.42P10.2fe5eef548819ba1cf9ab7c2",
"src.call.42P10.4cc3c771f6b98871572af1b5",
"src.call.42P10.9fb7b007472c34d677de2888"
],
"statement": "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."
}claims · versions.catalogue-boundary
{
"claim_id": "versions.catalogue-boundary",
"limits": "First observed release is a lower bound, not precise behavioral introduction.",
"method": "Read locked catalogue facts and definition snapshot.",
"position": 2,
"runtime": [],
"sources": [
"src.errcodes.42P10.18.6"
],
"statement": "Locked catalogue snapshots show this condition by PostgreSQL 7.4; source behavior here is fixed at PostgreSQL 18.6."
}messages · message.variant-1
{
"limits": "Placeholders remain dynamic source fields; no concrete runtime value is claimed.",
"message_id": "message.variant-1",
"path": "",
"position": 0,
"raw": {
"detail_templates": [],
"hint_templates": [],
"id": "message.variant-1",
"limits": "Placeholders remain dynamic source fields; no concrete runtime value is claimed.",
"primary_template": "only table \"%s\" can be referenced in check constraint",
"roles": [
{
"role": "errmsg",
"template": "only table \"%s\" can be referenced in check constraint"
}
],
"severity_source": "ERROR",
"sources": [
"src.call.42P10.2fe5eef548819ba1cf9ab7c2"
],
"sqlstate": "42P10"
},
"severity": "ERROR",
"sources": [
"src.call.42P10.2fe5eef548819ba1cf9ab7c2"
],
"templates": [
{
"kind": "primary",
"literal": "only table \" \" can be referenced in check constraint",
"position": 0,
"role": "",
"template": "only table \"%s\" can be referenced in check constraint"
}
]
}messages · message.variant-2
{
"limits": "Placeholders remain dynamic source fields; no concrete runtime value is claimed.",
"message_id": "message.variant-2",
"path": "",
"position": 1,
"raw": {
"detail_templates": [
"Generated columns cannot be used in COPY."
],
"hint_templates": [],
"id": "message.variant-2",
"limits": "Placeholders remain dynamic source fields; no concrete runtime value is claimed.",
"primary_template": "column \"%s\" is a generated column",
"roles": [
{
"role": "errmsg",
"template": "column \"%s\" is a generated column"
},
{
"role": "errdetail",
"template": "Generated columns cannot be used in COPY."
}
],
"severity_source": "ERROR",
"sources": [
"src.call.42P10.4cc3c771f6b98871572af1b5"
],
"sqlstate": "42P10"
},
"severity": "ERROR",
"sources": [
"src.call.42P10.4cc3c771f6b98871572af1b5"
],
"templates": [
{
"kind": "primary",
"literal": "column \" \" is a generated column",
"position": 0,
"role": "",
"template": "column \"%s\" is a generated column"
},
{
"kind": "detail",
"literal": "Generated columns cannot be used in COPY.",
"position": 1,
"role": "",
"template": "Generated columns cannot be used in COPY."
},
{
"kind": "primary",
"literal": "Generated columns cannot be used in COPY.",
"position": 2,
"role": "errdetail",
"template": "Generated columns cannot be used in COPY."
}
]
}messages · message.variant-3
{
"limits": "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.",
"message_id": "message.variant-3",
"path": "",
"position": 2,
"raw": {
"detail_templates": [],
"hint_templates": [],
"id": "message.variant-3",
"limits": "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.",
"primary_template": "there is no unique or exclusion constraint matching the ON CONFLICT specification",
"roles": [
{
"role": "errmsg",
"template": "there is no unique or exclusion constraint matching the ON CONFLICT specification"
}
],
"severity_source": "ERROR",
"sources": [
"src.call.42P10.9fb7b007472c34d677de2888"
],
"sqlstate": "42P10"
},
"severity": "ERROR",
"sources": [
"src.call.42P10.9fb7b007472c34d677de2888"
],
"templates": [
{
"kind": "primary",
"literal": "there is no unique or exclusion constraint matching the ON CONFLICT specification",
"position": 0,
"role": "",
"template": "there is no unique or exclusion constraint matching the ON CONFLICT specification"
}
]
}sources · src.errcodes.42P10.18.6
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "line 390",
"path": "src/backend/utils/errcodes.txt",
"position": 0,
"sha256": "6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba",
"source_id": "src.errcodes.42P10.18.6",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt#L390"
}sources · src.call.42P10.2fe5eef548819ba1cf9ab7c2
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "lines 3465-3468",
"path": "src/backend/catalog/heap.c",
"position": 1,
"sha256": "e720ee58279590793edd0985b3c910970ef56e7361b8ef92e245370587e02a0e",
"source_id": "src.call.42P10.2fe5eef548819ba1cf9ab7c2",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/catalog/heap.c#L3465-L3468"
}sources · src.call.42P10.4cc3c771f6b98871572af1b5
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "lines 1026-1030",
"path": "src/backend/commands/copy.c",
"position": 2,
"sha256": "f50ecc1531109fc172d841d461e209cef611f3d017ef4184034c39e128deabbe",
"source_id": "src.call.42P10.4cc3c771f6b98871572af1b5",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/commands/copy.c#L1026-L1030"
}sources · src.call.42P10.9fb7b007472c34d677de2888
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "lines 958-960",
"path": "src/backend/optimizer/util/plancat.c",
"position": 3,
"sha256": "b953af14cb2539fbb32e4d1e8eea30f3eaa1b6336091369c03531fb9dcd5a6ff",
"source_id": "src.call.42P10.9fb7b007472c34d677de2888",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/optimizer/util/plancat.c#L958-L960"
}sources · src.calls.REL_18_6.42P10
{
"commit": "",
"docs_url": "",
"kind": "local_artifact",
"location": "",
"path": "raw/calls/REL_18_6.jsonl",
"position": 4,
"sha256": "9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf",
"source_id": "src.calls.REL_18_6.42P10",
"tag": "",
"url": ""
}Source references
Full definition and evidence JSON
Definition sources
center · PostgreSQL 18 · english-manuals:ba6f1dd1a717b31f4f226abff0efa3e520b9e45966d5b266e946609534727bf4
Text language: en · english-manuals:ba6f1dd1a717b31f4f226abff0efa3e520b9e45966d5b266e946609534727bf4