↑↓ select↵ open⌫ change scopeOpen full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Wiki / SQLSTATE

42P17 — Invalid object definition

42P17 (invalid_object_definition) Object definitions can conflict through inheritance, generated columns, or rewrite 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_object_definition
lang
en
sqlstate
42P17

Definition PG 18

42P17 — Invalid object definition

At a glance {#at-a-glance}

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

Meaning {#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 {#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 {#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 {#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 {#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.

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.42P17.18.6"
  ],
  "statement": "42P17 is the invalid_object_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.42P17.7a6be8fbd1213811e253e016",
    "src.call.42P17.09eb0354822f0636e23d3677",
    "src.call.42P17.79a0f8a4009c621f6b3254f8"
  ],
  "statement": "Selected paths reject an inherited-constraint conflict whose parent/child inheritance flags do not permit the requested merge, a generated column referencing another generated column, and recursive rewrite rules. These object graphs require different repairs; the source does not support a universal remove-inherited-constraint rule."
}
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.42P17.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": "constraint \"%s\" conflicts with non-inherited constraint on relation \"%s\"",
    "roles": [
      {
        "role": "errmsg",
        "template": "constraint \"%s\" conflicts with non-inherited constraint on relation \"%s\""
      }
    ],
    "severity_source": "ERROR",
    "sources": [
      "src.call.42P17.7a6be8fbd1213811e253e016"
    ],
    "sqlstate": "42P17"
  },
  "severity": "ERROR",
  "sources": [
    "src.call.42P17.7a6be8fbd1213811e253e016"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "constraint \" \" conflicts with non-inherited constraint on relation \" \"",
      "position": 0,
      "role": "",
      "template": "constraint \"%s\" conflicts with non-inherited constraint on relation \"%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": [
      "A generated column cannot reference another generated column."
    ],
    "hint_templates": [],
    "id": "message.variant-2",
    "limits": "Placeholders remain dynamic source fields; no concrete runtime value is claimed.",
    "primary_template": "cannot use generated column \"%s\" in column generation expression",
    "roles": [
      {
        "role": "errmsg",
        "template": "cannot use generated column \"%s\" in column generation expression"
      },
      {
        "role": "errdetail",
        "template": "A generated column cannot reference another generated column."
      }
    ],
    "severity_source": "ERROR",
    "sources": [
      "src.call.42P17.09eb0354822f0636e23d3677"
    ],
    "sqlstate": "42P17"
  },
  "severity": "ERROR",
  "sources": [
    "src.call.42P17.09eb0354822f0636e23d3677"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "cannot use generated column \" \" in column generation expression",
      "position": 0,
      "role": "",
      "template": "cannot use generated column \"%s\" in column generation expression"
    },
    {
      "kind": "detail",
      "literal": "A generated column cannot reference another generated column.",
      "position": 1,
      "role": "",
      "template": "A generated column cannot reference another generated column."
    },
    {
      "kind": "primary",
      "literal": "A generated column cannot reference another generated column.",
      "position": 2,
      "role": "errdetail",
      "template": "A generated column cannot reference another generated column."
    }
  ]
}
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": "infinite recursion detected in rules for relation \"%s\"",
    "roles": [
      {
        "role": "errmsg",
        "template": "infinite recursion detected in rules for relation \"%s\""
      }
    ],
    "severity_source": "ERROR",
    "sources": [
      "src.call.42P17.79a0f8a4009c621f6b3254f8"
    ],
    "sqlstate": "42P17"
  },
  "severity": "ERROR",
  "sources": [
    "src.call.42P17.79a0f8a4009c621f6b3254f8"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "infinite recursion detected in rules for relation \" \"",
      "position": 0,
      "role": "",
      "template": "infinite recursion detected in rules for relation \"%s\""
    }
  ]
}
sources · src.errcodes.42P17.18.6
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "line 398",
  "path": "src/backend/utils/errcodes.txt",
  "position": 0,
  "sha256": "6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba",
  "source_id": "src.errcodes.42P17.18.6",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt#L398"
}
sources · src.call.42P17.7a6be8fbd1213811e253e016
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "lines 2820-2823",
  "path": "src/backend/catalog/heap.c",
  "position": 1,
  "sha256": "e720ee58279590793edd0985b3c910970ef56e7361b8ef92e245370587e02a0e",
  "source_id": "src.call.42P17.7a6be8fbd1213811e253e016",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/catalog/heap.c#L2820-L2823"
}
sources · src.call.42P17.09eb0354822f0636e23d3677
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "lines 3237-3242",
  "path": "src/backend/catalog/heap.c",
  "position": 2,
  "sha256": "e720ee58279590793edd0985b3c910970ef56e7361b8ef92e245370587e02a0e",
  "source_id": "src.call.42P17.09eb0354822f0636e23d3677",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/catalog/heap.c#L3237-L3242"
}
sources · src.call.42P17.79a0f8a4009c621f6b3254f8
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "lines 2164-2167",
  "path": "src/backend/rewrite/rewriteHandler.c",
  "position": 3,
  "sha256": "5a34bf31f424abbf46cd926da1fefcd9360c4d527a87d8a0ac9f653d67c2206a",
  "source_id": "src.call.42P17.79a0f8a4009c621f6b3254f8",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/rewrite/rewriteHandler.c#L2164-L2167"
}
sources · src.calls.REL_18_6.42P17
{
  "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.42P17",
  "tag": "",
  "url": ""
}

Source references

Full definition and evidence JSON

Definition sources

center · PostgreSQL 18 · english-manuals:903b0d33cf825e8f23c8a3810ba67f8cdae1014d55c5cd9bc1888a5abbb0b69f

Text language: en · english-manuals:903b0d33cf825e8f23c8a3810ba67f8cdae1014d55c5cd9bc1888a5abbb0b69f