42P16 — Invalid table definition
42P16 (invalid_table_definition) A table definition can violate partition-key, collation, or primary-key rules.
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_table_definition
- lang
- en
- sqlstate
- 42P16
Definition PG 18
42P16 — Invalid table definition
At a glance {#at-a-glance}
42P16 (invalid_table_definition) A table definition can violate partition-key, collation, or primary-key rules.
Meaning {#meaning}
Table-definition checks use this condition for several relation-shape violations. Core 18.6 examples reject pseudo-types in partition keys, missing collation for a collatable partition key, and multiple primary keys.
Diagnosis {#diagnosis}
Use the exact message to identify the table and column. Inspect pg_attribute/pg_type for the partition key type, determine the collation explicitly for collatable types, and list existing primary constraints before changing DDL.
Response {#response}
Change only the conflicting table definition: use a supported concrete partition-key type, add an explicit COLLATE where the source requires it, or retain one intended primary key and remove the duplicate declaration from the migration. If this ERROR occurs inside an explicit transaction, ROLLBACK or ROLLBACK TO a pre-error savepoint before issuing the corrected DDL; do not keep sending table changes in the aborted transaction.
Messages {#messages}
Representative source messages include: message: partition key column %s has pseudo-type %s; message: no collation was derived for partition key column %s with collatable type %s; HINT: Use the COLLATE clause to set the collation explicitly.; message: multiple primary keys for table "%s" are not allowed. 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:576-580(fixed source)src/backend/catalog/heap.c:697-702(fixed source)src/backend/catalog/index.c:218-221(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.42P16.18.6"
],
"statement": "42P16 is the invalid_table_definition condition in Class 42."
}claims · mechanism.selected-source-path
{
"claim_id": "mechanism.selected-source-path",
"limits": "Representative confirmed core paths only; not exhaustive historical or extension coverage.",
"method": "Read selected resolved REL_18_6 report groups and message roles.",
"position": 1,
"runtime": [],
"sources": [
"src.call.42P16.af3eab51674420e4a935dec6",
"src.call.42P16.ba3688fe3791594da97fde08",
"src.call.42P16.ca2b8fc15fc050d4a6cd2d3b"
],
"statement": "Table-definition checks use this condition for several relation-shape violations. Core 18.6 examples reject pseudo-types in partition keys, missing collation for a collatable partition key, and multiple primary keys."
}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.42P16.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": "partition key column %s has pseudo-type %s",
"roles": [
{
"role": "errmsg",
"template": "partition key column %s has pseudo-type %s"
}
],
"severity_source": "ERROR",
"sources": [
"src.call.42P16.af3eab51674420e4a935dec6"
],
"sqlstate": "42P16"
},
"severity": "ERROR",
"sources": [
"src.call.42P16.af3eab51674420e4a935dec6"
],
"templates": [
{
"kind": "primary",
"literal": "partition key column has pseudo-type",
"position": 0,
"role": "",
"template": "partition key column %s has pseudo-type %s"
}
]
}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": [],
"hint_templates": [
"Use the COLLATE clause to set the collation explicitly."
],
"id": "message.variant-2",
"limits": "Placeholders remain dynamic source fields; no concrete runtime value is claimed.",
"primary_template": "no collation was derived for partition key column %s with collatable type %s",
"roles": [
{
"role": "errmsg",
"template": "no collation was derived for partition key column %s with collatable type %s"
},
{
"role": "errhint",
"template": "Use the COLLATE clause to set the collation explicitly."
}
],
"severity_source": "ERROR",
"sources": [
"src.call.42P16.ba3688fe3791594da97fde08"
],
"sqlstate": "42P16"
},
"severity": "ERROR",
"sources": [
"src.call.42P16.ba3688fe3791594da97fde08"
],
"templates": [
{
"kind": "primary",
"literal": "no collation was derived for partition key column with collatable type",
"position": 0,
"role": "",
"template": "no collation was derived for partition key column %s with collatable type %s"
},
{
"kind": "hint",
"literal": "Use the COLLATE clause to set the collation explicitly.",
"position": 1,
"role": "",
"template": "Use the COLLATE clause to set the collation explicitly."
},
{
"kind": "primary",
"literal": "Use the COLLATE clause to set the collation explicitly.",
"position": 2,
"role": "errhint",
"template": "Use the COLLATE clause to set the collation explicitly."
}
]
}messages · message.variant-3
{
"limits": "Placeholders remain dynamic source fields; no concrete runtime value is claimed.",
"message_id": "message.variant-3",
"path": "",
"position": 2,
"raw": {
"detail_templates": [],
"hint_templates": [],
"id": "message.variant-3",
"limits": "Placeholders remain dynamic source fields; no concrete runtime value is claimed.",
"primary_template": "multiple primary keys for table \"%s\" are not allowed",
"roles": [
{
"role": "errmsg",
"template": "multiple primary keys for table \"%s\" are not allowed"
}
],
"severity_source": "ERROR",
"sources": [
"src.call.42P16.ca2b8fc15fc050d4a6cd2d3b"
],
"sqlstate": "42P16"
},
"severity": "ERROR",
"sources": [
"src.call.42P16.ca2b8fc15fc050d4a6cd2d3b"
],
"templates": [
{
"kind": "primary",
"literal": "multiple primary keys for table \" \" are not allowed",
"position": 0,
"role": "",
"template": "multiple primary keys for table \"%s\" are not allowed"
}
]
}sources · src.errcodes.42P16.18.6
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "line 397",
"path": "src/backend/utils/errcodes.txt",
"position": 0,
"sha256": "6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba",
"source_id": "src.errcodes.42P16.18.6",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt#L397"
}sources · src.call.42P16.af3eab51674420e4a935dec6
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "lines 576-580",
"path": "src/backend/catalog/heap.c",
"position": 1,
"sha256": "e720ee58279590793edd0985b3c910970ef56e7361b8ef92e245370587e02a0e",
"source_id": "src.call.42P16.af3eab51674420e4a935dec6",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/catalog/heap.c#L576-L580"
}sources · src.call.42P16.ba3688fe3791594da97fde08
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "lines 697-702",
"path": "src/backend/catalog/heap.c",
"position": 2,
"sha256": "e720ee58279590793edd0985b3c910970ef56e7361b8ef92e245370587e02a0e",
"source_id": "src.call.42P16.ba3688fe3791594da97fde08",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/catalog/heap.c#L697-L702"
}sources · src.call.42P16.ca2b8fc15fc050d4a6cd2d3b
{
"commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
"docs_url": "",
"kind": "upstream_source",
"location": "lines 218-221",
"path": "src/backend/catalog/index.c",
"position": 3,
"sha256": "98a4156a5c21ae856a3b583b633cdeb578a5b69910386c9f166d69fcb04ba2d0",
"source_id": "src.call.42P16.ca2b8fc15fc050d4a6cd2d3b",
"tag": "REL_18_6",
"url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/catalog/index.c#L218-L221"
}sources · src.calls.REL_18_6.42P16
{
"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.42P16",
"tag": "",
"url": ""
}Source references
Full definition and evidence JSON
Definition sources
center · PostgreSQL 18 · english-manuals:9d8289f1c339d7a9caed76425827824e5d48b1a1d61eeb48db0b6bf8ac535326
Text language: en · english-manuals:9d8289f1c339d7a9caed76425827824e5d48b1a1d61eeb48db0b6bf8ac535326