↑↓ 选择↵ 打开⌫ 切换范围完整搜索

PG.CENTER 连接 PostgreSQL 文档、百科与生态知识。由 Pigsty 维护。

Wiki / SQLSTATE

27000 — triggered_data_change_violation(触发的数据更改违规)

触发器操作重复修改了当前命令已改动的行。

英文手册覆盖始于 PostgreSQL 8.1. 来源历史与运行验证各自保留独立版本边界。

当前阅读 PG 18·选择有来源记录的版本

aliases
未知
class name
Triggered Data Change Violation
condition name
triggered_data_change_violation
lang
en
sqlstate
27000

版本定义 PG 18

27000 — triggered_data_change_violation(触发的数据更改违规)

速览 {#at-a-glance}

27000 是源码确认的触发器保护条件。当当前命令触发的操作已经修改某行时,PostgreSQL 会使用这个码;18.6 固定源码的提示建议在需要向其他行传播变化时考虑 AFTER trigger。简单的“自身更新” BEFORE trigger 可能递归或改变触发器语义,因此本页不把它伪装成通用安全复现。

含义 {#meaning}

27000 是执行器在“当前命令触发的操作已经修改过该元组”时发出的触发数据更改违规。固定的 trigger.c 路径针对同一命令、同一元组的触发器改写保护;它不是所有触发器异常或递归触发器的统称。

诊断 {#diagnosis}

先确认目标表、命令影响的行以及可能再次更新该行的 BEFORE 行级触发器。固定主模板是 tuple to be updated was already modified by an operation triggered by the current command,提示可考虑用 AFTER 触发器向其他行传播变化。只会递归的自更新测试属于另一种故障,不能证明这条路径。本批没有自然运行观察;若线上真实触发,应同时保存客户端实际事务状态。

处理 {#response}

如果触发器是在向其他行传播变化,符合语义时可以改用 AFTER 触发器或一次集合式语句;若同一元组确实被两次命中,应重新设计触发器。不能套用通用重试或 CASCADE,也不能把人为构造的自更新递归说成 27000。真实显式事务失败后,先回滚再发修复 SQL。

版本 {#versions}

上面的锁定事实表记录项目快照范围内的目录存在情况。固定源码证据只覆盖下面声明的路径;不能仅从定义推导精确行为引入版本或更广的运行覆盖。

相关 {#related}

可对照44000 WITH CHECK OPTION 违规和23514 检查约束违规。

来源 {#sources}

  • src.errcodes.18.6(SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba)
  • 源码路径(SHA-256 0a539af85b0de1a04779f92202e7bfc77d85ae6da1747ea32527c67f39084fbd)

比较版本

SQLSTATE 证据与已记录的运行版本

cases · triggered_data_change_boundary
{
  "assertions": [],
  "case_id": "triggered_data_change_boundary",
  "cleanup": "Drop the case schema with an owner connection.",
  "has_snippet": false,
  "position": 0,
  "preconditions": [
    "A runner-owned disposable target is provisioned."
  ],
  "repair": "Use the source-confirmed trigger design and test it separately when the application can control the affected-row semantics.",
  "trigger": "No artificial trigger is executed; the page records the fixed source path and its safe-case boundary.",
  "versions": [
    "10",
    "18"
  ]
}
claims · identity
{
  "claim_id": "identity",
  "limits": "This records the protocol definition and does not imply a natural PostgreSQL throw path.",
  "method": "Read the fixed errcodes.txt row and macro mapping.",
  "position": 0,
  "runtime": [],
  "sources": [
    "src.errcodes.18.6"
  ],
  "statement": "27000 is the triggered_data_change_violation condition in Class 27."
}
claims · source-boundary
{
  "claim_id": "source-boundary",
  "limits": "No representative runtime case is claimed; the path requires a specialized internal or trigger/procedure context.",
  "method": "Trace the fixed source call scan and classify the path before selecting a safe runner case.",
  "position": 1,
  "runtime": [],
  "sources": [
    "src.trigger.18.6",
    "src.calls.REL_18_6"
  ],
  "statement": "tuple to be updated was already modified by an operation triggered by the current command is a source-confirmed path for 27000."
}
messages · message.triggered-data-change
{
  "limits": "The hint and any row identity are contextual; this is the fixed BEFORE-trigger same-tuple branch.",
  "message_id": "message.triggered-data-change",
  "path": "",
  "position": 0,
  "raw": {
    "id": "message.triggered-data-change",
    "limits": "The hint and any row identity are contextual; this is the fixed BEFORE-trigger same-tuple branch.",
    "primary_template": "tuple to be updated was already modified by an operation triggered by the current command",
    "severity_source": "ERROR",
    "sources": [
      "src.trigger.18.6"
    ],
    "sqlstate": "27000"
  },
  "severity": "ERROR",
  "sources": [
    "src.trigger.18.6"
  ],
  "templates": [
    {
      "kind": "primary",
      "literal": "tuple to be updated was already modified by an operation triggered by the current command",
      "position": 0,
      "role": "",
      "template": "tuple to be updated was already modified by an operation triggered by the current command"
    }
  ]
}
messages · message.triggered-data-change-hint
{
  "limits": "The hint describes this source branch and is not a universal trigger migration rule.",
  "message_id": "message.triggered-data-change-hint",
  "path": "",
  "position": 1,
  "raw": {
    "hint_template": "Consider using an AFTER trigger instead of a BEFORE trigger to propagate changes to other rows.",
    "id": "message.triggered-data-change-hint",
    "limits": "The hint describes this source branch and is not a universal trigger migration rule.",
    "severity_source": "ERROR",
    "sources": [
      "src.trigger.18.6"
    ],
    "sqlstate": "27000"
  },
  "severity": "ERROR",
  "sources": [
    "src.trigger.18.6"
  ],
  "templates": [
    {
      "kind": "hint",
      "literal": "Consider using an AFTER trigger instead of a BEFORE trigger to propagate changes to other rows.",
      "position": 0,
      "role": "",
      "template": "Consider using an AFTER trigger instead of a BEFORE trigger to propagate changes to other rows."
    }
  ]
}
sources · src.errcodes.18.6
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/utils/errcodes.txt",
  "position": 0,
  "sha256": "6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba",
  "source_id": "src.errcodes.18.6",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt"
}
sources · src.calls.REL_18_6
{
  "commit": "",
  "docs_url": "",
  "kind": "local_artifact",
  "location": "",
  "path": "raw/calls/REL_18_6.jsonl",
  "position": 1,
  "sha256": "9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf",
  "source_id": "src.calls.REL_18_6",
  "tag": "",
  "url": ""
}
sources · src.trigger.18.6
{
  "commit": "724edf9bde9d356724ad384a2e196edc3c9f80f7",
  "docs_url": "",
  "kind": "upstream_source",
  "location": "",
  "path": "src/backend/commands/trigger.c",
  "position": 2,
  "sha256": "0a539af85b0de1a04779f92202e7bfc77d85ae6da1747ea32527c67f39084fbd",
  "source_id": "src.trigger.18.6",
  "tag": "REL_18_6",
  "url": "https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/commands/trigger.c#L3404-L3407"
}

来源引用

完整定义与证据 JSON

定义来源

center · PostgreSQL 18 · english-manuals:67f7917e6f8a1e33fb5bf8cabb0e64c872c4782d3fc5e2088b8288cac3ebec7d

正文语言: zh-Hans · english-manuals:67f7917e6f8a1e33fb5bf8cabb0e64c872c4782d3fc5e2088b8288cac3ebec7d