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

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

Wiki / SQLSTATE

40002 — transaction_integrity_constraint_violation(事务完整性约束违规)

事务级完整性约束违规的总括码,核心不直接使用。

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

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

aliases
未知
class name
Transaction Rollback
condition name
transaction_integrity_constraint_violation
lang
en
sqlstate
40002

版本定义 PG 18

40002 — transaction_integrity_constraint_violation(事务完整性约束违规)

速览 {#at-a-glance}

40002 是目录定义的事务完整性条件。本批固定扫描没有解析出独立的 PostgreSQL 核心 40002 抛出点,因此不把外键、唯一性或其他具体约束错误重新标成这个总括码。应保存操作实际发出的 SQLSTATE。

含义 {#meaning}

40002 表示 40 类的事务完整性约束违规,但固定的 PostgreSQL 核心扫描没有解析出独立的 40002 调用点。PostgreSQL 的具体完整性机制通常报告 23 类具体码,例如 23502、23503、23505、23514 或 23P01。

诊断 {#diagnosis}

从错误中读取实际 SQLSTATE、约束名、关系、列和 DETAIL。服务器给出具体 23 类码时,应按该约束及事务状态诊断;不能因为操作发生在事务中就升级为 40002。本页没有选定的自然运行案例,也没有服务器特定报文模板。

处理 {#response}

修复具体约束违规和事务边界,再核对预期持久化状态。不要添加通用重试,也不要把已知 235xx/23P01 结果改称 40002;只有真实组件提供该码及其证据时才使用这一类定义。

版本 {#versions}

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

相关 {#related}

服务器给出具体完整性码时,应使用它,例如23503 外键违规或23505 唯一性违规。

来源 {#sources}

  • src.errcodes.18.6(SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba)
  • 固定调用扫描 src.calls.REL_18_6(SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf)

比较版本

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

cases · transaction_integrity_boundary
{
  "assertions": [],
  "case_id": "transaction_integrity_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 concrete SQLSTATE emitted by the actual operation and reconcile the transaction outcome before retrying.",
  "trigger": "No natural core 40002 path was resolved in the fixed scan, so no SQL trigger is fabricated.",
  "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": "40002 is the transaction_integrity_constraint_violation condition in Class 40."
}
claims · no-safe-natural-case
{
  "claim_id": "no-safe-natural-case",
  "limits": "This is a bounded source/definition result, not proof that every extension or injected fault cannot emit the code.",
  "method": "Review the fixed call scan for resolved 40002 call groups and reject artificial RAISE or relabeling.",
  "position": 1,
  "runtime": [],
  "sources": [
    "src.calls.REL_18_6"
  ],
  "statement": "No distinct safe natural core runtime case for 40002 was selected from the fixed call scan."
}
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": ""
}

来源引用

完整定义与证据 JSON

定义来源

center · PostgreSQL 18 · english-manuals:90e4e015c82d01e0e83740890ff9bb2145425be4098a1fdea9196d09b2b6005d

正文语言: zh-Hans · english-manuals:90e4e015c82d01e0e83740890ff9bb2145425be4098a1fdea9196d09b2b6005d