42P17 — 无效对象定义
对象定义无效,如继承、生成列或规则冲突。
英文手册覆盖始于 PostgreSQL 8.1. 来源历史与运行验证各自保留独立版本边界。
当前阅读 PG 18·选择有来源记录的版本
- aliases
- 未知
- class name
- Syntax Error or Access Rule Violation
- condition name
- invalid_object_definition
- lang
- en
- sqlstate
- 42P17
版本定义 PG 18
42P17 — 无效对象定义
速览 {#at-a-glance}
42P17(invalid_object_definition)对象定义可能在继承、生成列或重写规则上冲突。
含义 {#meaning}
对象定义校验覆盖对象关系以及生成列/规则定义。选定路径拒绝继承约束冲突、生成列引用另一个生成列,以及规则递归。
诊断 {#diagnosis}
按消息中点名的对象分类:关系继承、生成列表达式,还是重写规则。检查 pg_inherits 与父子约束定义/继承标志、完整生成表达式或 pg_rewrite 规则;这些路径的修复方式不同。
处理 {#response}
对于继承约束冲突,比较父子定义和继承标志,并按预期继承契约对齐;不要一概删除继承约束。让生成列表达式只依赖允许的基础列,或打破重写规则环。重试 DDL 前重新检查对象图;仅重命名不能修复递归规则。如果 ERROR 发生在显式事务中,下一次 DDL 前先 ROLLBACK 或回滚到错误前的保存点。
消息 {#messages}
固定源码中的代表性消息包括: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"。占位符由实际对象、列或参数填充。
版本 {#versions}
锁定目录显示该条件最早见于 PostgreSQL 7.4;行为说明固定在 PostgreSQL 18.6 源码,目录存在范围不等于每条消息或功能都从该版本开始。
相关 {#related}
来源 {#sources}
源码消息、行号和证据边界见 作者证据。
src/backend/catalog/heap.c:2820-2823(fixed source)src/backend/catalog/heap.c:3237-3242(fixed source)src/backend/rewrite/rewriteHandler.c:2164-2167(fixed source)
比较版本
SQLSTATE 证据与已记录的运行版本
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": ""
}来源引用
定义来源
center · PostgreSQL 18 · english-manuals:903b0d33cf825e8f23c8a3810ba67f8cdae1014d55c5cd9bc1888a5abbb0b69f
正文语言: zh-Hans · english-manuals:903b0d33cf825e8f23c8a3810ba67f8cdae1014d55c5cd9bc1888a5abbb0b69f