选择 打开 改范围 完整检索页

pgsql.cc 提供对 postgresql.org 官网内容的中文翻译,由 Pigsty 团队维护。

百科 / 错误代码 / Class 42 语法错误或访问规则冲突

42P17 invalid_object_definition

无效对象定义

ERROR 源码确认 参考 未实测

条件名
invalid_object_definition
宏名称
ERRCODE_INVALID_OBJECT_DEFINITION
启用版本
7.4
状态
活跃

版本覆盖

速览

42P17invalid_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
DETAIL A generated column cannot reference another generated column.
主消息 · errdetail 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 源码,目录存在范围不等于每条消息或功能都从该版本开始。

来源

证据

断言

每条断言都写明了是怎么核实的,以及它不覆盖什么。这一层是核验时留下的原始英文记录,照原样呈现,未经翻译。

  • 42P17 is the invalid_object_definition condition in Class 42.

    核实方式Read fixed REL_18_6 errcodes.txt and locked facts.

    不覆盖Identity does not enumerate all source branches or client failures.

    来源src/backend/utils/errcodes.txt(line 398)

  • 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.

    核实方式Read selected resolved REL_18_6 report groups and message roles.

    不覆盖Representative confirmed core paths only; not exhaustive historical or extension coverage.

    来源src/backend/catalog/heap.c(lines 2820-2823) · src/backend/catalog/heap.c(lines 3237-3242) · src/backend/rewrite/rewriteHandler.c(lines 2164-2167)

  • Locked catalogue snapshots show this condition by PostgreSQL 7.4; source behavior here is fixed at PostgreSQL 18.6.

    核实方式Read locked catalogue facts and definition snapshot.

    不覆盖First observed release is a lower bound, not precise behavioral introduction.

    来源src/backend/utils/errcodes.txt(line 398)

同类错误代码

Class 42 语法错误或访问规则冲突 下的其他成员。