Skip to content

42P16 — Invalid table definition

Source-backed reference for PostgreSQL SQLSTATE 42P16.

42P16 — Invalid table definition

At a glance

42P16 (invalid_table_definition) A table definition can violate partition-key, collation, or primary-key rules.

Field Value
SQLSTATE 42P16
Condition invalid_table_definition
Status active
Known present by 7.4
Locked snapshots 9.0.23, 9.1.24, 9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3
Macros ERRCODE_INVALID_TABLE_DEFINITION
Aliases

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

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

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

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

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.