百科 / 错误代码 / Class 27 触发数据变更冲突
27000 triggered_data_change_violation
触发的数据更改违规
ERROR 源码确认 参考 未实测
- 条件名
triggered_data_change_violation- 宏名称
ERRCODE_TRIGGERED_DATA_CHANGE_VIOLATION- 启用版本
- 7.4
- 状态
- 活跃
版本覆盖
速览
27000 是源码确认的触发器保护条件。当当前命令触发的操作已经修改某行时,PostgreSQL 会使用这个码;18.6 固定源码的提示建议在需要向其他行传播变化时考虑 AFTER trigger。简单的“自身更新” BEFORE trigger 可能递归或改变触发器语义,因此本页不把它伪装成通用安全复现。
含义
27000 是执行器在“当前命令触发的操作已经修改过该元组”时发出的触发数据更改违规。固定的 trigger.c 路径针对同一命令、同一元组的触发器改写保护;它不是所有触发器异常或递归触发器的统称。
报文模板
源码里的格式串,不是某一次运行的输出。%s 之类是占位符,实际报文会填入对象名与取值。适用范围一栏是核验时留下的原始英文记录,未经翻译。
tuple to be updated was already modified by an operation triggered by the current command
来源:src/backend/commands/trigger.c @ REL_18_6
适用范围:The hint and any row identity are contextual; this is the fixed BEFORE-trigger same-tuple branch.
Consider using an AFTER trigger instead of a BEFORE trigger to propagate changes to other rows.
来源:src/backend/commands/trigger.c @ REL_18_6
适用范围:The hint describes this source branch and is not a universal trigger migration rule.
诊断
先确认目标表、命令影响的行以及可能再次更新该行的 BEFORE 行级触发器。固定主模板是 tuple to be updated was already modified by an operation triggered by the current command,提示可考虑用 AFTER 触发器向其他行传播变化。只会递归的自更新测试属于另一种故障,不能证明这条路径。本批没有自然运行观察;若线上真实触发,应同时保存客户端实际事务状态。
处理
如果触发器是在向其他行传播变化,符合语义时可以改用 AFTER 触发器或一次集合式语句;若同一元组确实被两次命中,应重新设计触发器。不能套用通用重试或 CASCADE,也不能把人为构造的自更新递归说成 27000。真实显式事务失败后,先回滚再发修复 SQL。
可复现案例
在一次性实例上执行过的场景。
triggered_data_change_boundary PG 10 / 18
前置条件
- A runner-owned disposable target is provisioned.
触发
No artificial trigger is executed; the page records the fixed source path and its safe-case boundary.
处置
Use the source-confirmed trigger design and test it separately when the application can control the affected-row semantics.
清理
Drop the case schema with an owner connection.
版本
上面的锁定事实表记录项目快照范围内的目录存在情况。固定源码证据只覆盖下面声明的路径;不能仅从定义推导精确行为引入版本或更广的运行覆盖。
来源
- 上游源码 src/backend/utils/errcodes.txt
- 上游源码 src/backend/commands/trigger.c 第 3404–3407 行
- 核验材料 raw/calls/REL_18_6.jsonl
证据
断言
每条断言都写明了是怎么核实的,以及它不覆盖什么。这一层是核验时留下的原始英文记录,照原样呈现,未经翻译。
-
27000 is the triggered_data_change_violation condition in Class 27.
-
tuple to be updated was already modified by an operation triggered by the current command is a source-confirmed path for 27000.