23000 — 完整性约束冲突(integrity_constraint_violation)
完整性约束冲突的类别码,应使用具体子码。
英文手册覆盖始于 PostgreSQL 8.1. 来源历史与运行验证各自保留独立版本边界。
当前阅读 PG 18·选择有来源记录的版本
- aliases
- 未知
- class name
- Integrity Constraint Violation
- condition name
- integrity_constraint_violation
- lang
- en
- sqlstate
- 23000
版本定义 PG 18
23000 — 完整性约束冲突
速览 {#at-a-glance}
23000 是 Class 23 完整性约束冲突的总类名,不是可以替代具体错误码的自然触发码。客户端应使用服务器返回的完整五字符 SQLSTATE。
含义 {#meaning}
该类包含违反声明完整性规则的行和模式操作。锁定的 errcodes.txt 将具体机制分到 23001、23502、23503、23505、23514、23P01 等子码;18.6 核心调用扫描没有解析出的 23000 报文路径,因此本文不伪造运行复现。
诊断 {#diagnosis}
先读取精确 SQLSTATE,再查看 constraint_name、table_name、column_name、schema_name 以及主报文/DETAIL。把所有 Class 23 错误压成 23000 会丢失修复所需的对象和机制。
处理 {#response}
保留原语句及事务边界,按具体子码修复数据或约束;显式事务报错后先回滚。不要用 RAISE ... ERRCODE 23000 冒充自然服务器机制。
源码报文模板 {#messages}
适用边界 {#case}
本批没有为 23000 构造自然 SQL 触发器;请把它视为源码/协议边界,而不是可直接复制的复现脚本。结构化证据 · 案例导出。
作者证据 ID:identity, specific-codes, handling。选定运行记录:—。
版本与边界 {#versions}
锁定目录在 7.4 已观察到该总类,并在列出的 9.0–18.6 正式快照中均存在。18.6 调用扫描确认了有界源码观察;本文不把它解释为扩展或未来版本都不可能发出该码。
相关 {#related}
参见 23001 RESTRICT 冲突、23502 非空约束冲突、23514 CHECK 冲突、23P01 排除约束冲突 和 23505 唯一约束冲突。
来源 {#sources}
src.errcodes.18.6(SHA-2566e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba)src.calls.REL_18_6(SHA-2569ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf)
比较版本
SQLSTATE 证据与已记录的运行版本
claims · identity
{
"claim_id": "identity",
"limits": "The umbrella code is a protocol definition; concrete PostgreSQL constraint paths normally use a more specific Class 23 code.",
"method": "Read the fixed class and condition row.",
"position": 0,
"runtime": [],
"sources": [
"src.errcodes.18.6"
],
"statement": "23000 is the Class 23 integrity_constraint_violation umbrella condition."
}claims · specific-codes
{
"claim_id": "specific-codes",
"limits": "Absence from this scan is not proof that every extension or future source path can never emit 23000; it bounds this locked core scan.",
"method": "Compare the errcodes mapping with all resolved report groups whose code_candidates contain 23000.",
"position": 1,
"runtime": [],
"sources": [
"src.errcodes.18.6",
"src.calls.REL_18_6"
],
"statement": "PostgreSQL source uses specific descendants such as 23001, 23502, 23503, 23505, 23514, and 23P01 for distinct mechanisms; the exhaustive 18.6 call scan has no resolved 23000 report group."
}claims · handling
{
"claim_id": "handling",
"limits": "Do not fabricate a natural 23000 reproduction with RAISE; this batch has no safe core SQL path for it.",
"method": "Read the protocol identity and the specific descendant mappings.",
"position": 2,
"runtime": [],
"sources": [
"src.errcodes.18.6"
],
"statement": "A client should branch on the exact five-character SQLSTATE and use constraint/object fields rather than collapsing every Class 23 error to 23000."
}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": ""
}来源引用
定义来源
center · PostgreSQL 18 · english-manuals:dfb075259b1f05c585b6419eae8555a547c1fb8bcd43ecbfd8603af86c861748
正文语言: zh-Hans · english-manuals:dfb075259b1f05c585b6419eae8555a547c1fb8bcd43ecbfd8603af86c861748