Skip to content

42P17 — Invalid object definition

Source-backed reference for PostgreSQL SQLSTATE 42P17.

42P17 — Invalid object definition

At a glance

42P17 (invalid_object_definition) Object definitions can conflict through inheritance, generated columns, or rewrite rules.

Field Value
SQLSTATE 42P17
Condition invalid_object_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_OBJECT_DEFINITION
Aliases

Meaning

Object-definition validation covers object relationships and generated/rule definitions. Selected paths reject an inherited constraint conflict, a generated column referencing another generated column, and recursive rules.

Diagnosis

Classify the object named in the message: relation inheritance, generated-column expression, or rewrite rule. Inspect pg_inherits and constraint inheritance, the full generated expression, or pg_rewrite rules; these paths require different repairs.

Response

For an inherited-constraint conflict, compare the parent/child definitions and inheritance flags and align them with the intended inheritance contract; do not universally remove an inherited constraint. Make a generated expression depend only on permitted base columns, or break the rewrite-rule cycle. Recheck the resulting object graph before rerunning DDL; renaming alone does not repair a recursive rule. If an ERROR occurs inside an explicit transaction, ROLLBACK or ROLLBACK TO a pre-error savepoint before another DDL attempt.

Messages

Representative source messages include: message: constraint "%s" conflicts with non-inherited constraint on relation "%s"; message: cannot use generated column "%s" in column generation expression; DETAIL: A generated column cannot reference another generated column.; message: infinite recursion detected in rules for relation "%s". 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.