40002 — transaction_integrity_constraint_violation
40002 is a catalogue-defined transaction-integrity condition. No distinct PostgreSQL core 40002 call site was resolved in the fixed scan used for this batch, so no foreign-key, unique, or other concrete constraint error is relabeled as this umbrella code. Capture the actual SQLSTATE emitted by the operation.
English manual coverage begins with PostgreSQL 8.1. Source history and runtime observations have their own recorded version boundaries.
Reading PG 18·Select a recorded version
- aliases
- Unknown
- class name
- Transaction Rollback
- condition name
- transaction_integrity_constraint_violation
- lang
- en
- sqlstate
- 40002
Definition PG 18
40002 — transaction_integrity_constraint_violation
At a glance {#at-a-glance}
40002 is a catalogue-defined transaction-integrity condition. No distinct PostgreSQL core 40002 call site was resolved in the fixed scan used for this batch, so no foreign-key, unique, or other concrete constraint error is relabeled as this umbrella code. Capture the actual SQLSTATE emitted by the operation.
Meaning {#meaning}
40002 names transaction integrity constraint violation in Class 40, but the fixed PostgreSQL core scan did not resolve a distinct 40002 call site. PostgreSQL's concrete integrity mechanisms normally report a specific Class 23 code, such as 23502, 23503, 23505, 23514, or 23P01.
Diagnosis {#diagnosis}
Read the actual SQLSTATE, constraint name, relation, column, and DETAIL from the error. If the server reports a concrete Class 23 code, diagnose that constraint and its transaction state; do not promote it to 40002 because the operation was transactional. This page has no selected natural runtime case or server-specific message template.
Response {#response}
Repair the concrete constraint violation and its transaction boundary, then verify the intended durable state. Do not add a generic retry or relabel a known 235xx/23P01 result as 40002; use this class definition only when a real component supplies that code and its own evidence.
Versions {#versions}
The locked facts table records catalogue presence across the project snapshot range. The fixed source evidence is limited to the path stated below; no exact behavioral introduction or broader runtime coverage is inferred from the definition alone.
Related {#related}
Use the concrete integrity code, such as 23503 foreign-key violation or 23505 unique violation, when the server provides one.
Sources {#sources}
src.errcodes.18.6(SHA-2566e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba)src.calls.REL_18_6fixed call scan (SHA-2569ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf)
Compare versions
SQLSTATE evidence and recorded runtime versions
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": ""
}Source references
Full definition and evidence JSON
Definition sources
center · PostgreSQL 18 · english-manuals:90e4e015c82d01e0e83740890ff9bb2145425be4098a1fdea9196d09b2b6005d
Text language: en · english-manuals:90e4e015c82d01e0e83740890ff9bb2145425be4098a1fdea9196d09b2b6005d