百科 / 错误代码 / Class 42 语法错误或访问规则冲突
42P17 invalid_object_definition
无效对象定义
ERROR 源码确认 参考 未实测
- 条件名
invalid_object_definition- 宏名称
ERRCODE_INVALID_OBJECT_DEFINITION- 启用版本
- 7.4
- 状态
- 活跃
版本覆盖
速览
42P17(invalid_object_definition)对象定义可能在继承、生成列或重写规则上冲突。
含义
对象定义校验覆盖对象关系以及生成列/规则定义。选定路径拒绝继承约束冲突、生成列引用另一个生成列,以及规则递归。
诊断
按消息中点名的对象分类:关系继承、生成列表达式,还是重写规则。检查 pg_inherits 与父子约束定义/继承标志、完整生成表达式或 pg_rewrite 规则;这些路径的修复方式不同。
处理
对于继承约束冲突,比较父子定义和继承标志,并按预期继承契约对齐;不要一概删除继承约束。让生成列表达式只依赖允许的基础列,或打破重写规则环。重试 DDL 前重新检查对象图;仅重命名不能修复递归规则。如果 ERROR 发生在显式事务中,下一次 DDL 前先 ROLLBACK 或回滚到错误前的保存点。
消息
固定源码中的代表性消息包括: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"。占位符由实际对象、列或参数填充。
报文模板
源码里的格式串,不是某一次运行的输出。%s 之类是占位符,实际报文会填入对象名与取值。适用范围一栏是核验时留下的原始英文记录,未经翻译。
constraint "%s" conflicts with non-inherited constraint on relation "%s"
来源:src/backend/catalog/heap.c(lines 2820-2823) @ REL_18_6
适用范围:Placeholders remain dynamic source fields; no concrete runtime value is claimed.
cannot use generated column "%s" in column generation expression
A generated column cannot reference another generated column.
A generated column cannot reference another generated column.
来源:src/backend/catalog/heap.c(lines 3237-3242) @ REL_18_6
适用范围:Placeholders remain dynamic source fields; no concrete runtime value is claimed.
infinite recursion detected in rules for relation "%s"
来源:src/backend/rewrite/rewriteHandler.c(lines 2164-2167) @ REL_18_6
适用范围:Placeholders remain dynamic source fields; no concrete runtime value is claimed.
版本
锁定目录显示该条件最早见于 PostgreSQL 7.4;行为说明固定在 PostgreSQL 18.6 源码,目录存在范围不等于每条消息或功能都从该版本开始。
来源
- 上游源码 src/backend/catalog/heap.c 第 3237–3242 行
- 上游源码 src/backend/rewrite/rewriteHandler.c 第 2164–2167 行
- 上游源码 src/backend/catalog/heap.c 第 2820–2823 行
- 上游源码 src/backend/utils/errcodes.txt 第 398 行
- 核验材料 raw/calls/REL_18_6.jsonl
证据
断言
每条断言都写明了是怎么核实的,以及它不覆盖什么。这一层是核验时留下的原始英文记录,照原样呈现,未经翻译。
-
42P17 is the invalid_object_definition condition in Class 42.
-
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.
-
Locked catalogue snapshots show this condition by PostgreSQL 7.4; source behavior here is fixed at PostgreSQL 18.6.
同类错误代码
Class 42 语法错误或访问规则冲突 下的其他成员。
42000syntax_error_or_access_rule_violation42501insufficient_privilege42601syntax_error42602invalid_name42611invalid_column_definition42622name_too_long42701duplicate_column42702ambiguous_column42703undefined_column42704undefined_object42710duplicate_object42712duplicate_alias42723duplicate_function42725ambiguous_function42803grouping_error42804datatype_mismatch42809wrong_object_type42830invalid_foreign_key42846cannot_coerce42883undefined_function428C9generated_always42939reserved_name42P01undefined_table42P02undefined_parameter42P03duplicate_cursor42P04duplicate_database42P05duplicate_prepared_statement42P06duplicate_schema42P07duplicate_table42P08ambiguous_parameter42P09ambiguous_alias42P10invalid_column_reference42P11invalid_cursor_definition42P12invalid_database_definition42P13invalid_function_definition42P14invalid_prepared_statement_definition42P15invalid_schema_definition42P16invalid_table_definition42P18indeterminate_datatype42P19invalid_recursion42P20windowing_error42P21collation_mismatch42P22indeterminate_collation