↑↓ select↵ open⌫ change scopeOpen full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

Wiki / SQLSTATE

23000 — integrity_constraint_violation

23000 names the Class 23 integrity-constraint umbrella. It is a protocol category, not a reliable substitute for a concrete PostgreSQL constraint error. Use the exact five-character code returned by the server.

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
Integrity Constraint Violation
condition name
integrity_constraint_violation
lang
en
sqlstate
23000

Definition PG 18

23000 — integrity_constraint_violation

At a glance {#at-a-glance}

23000 names the Class 23 integrity-constraint umbrella. It is a protocol category, not a reliable substitute for a concrete PostgreSQL constraint error. Use the exact five-character code returned by the server.

Meaning {#meaning}

The class covers row and schema operations that violate declared integrity rules. PostgreSQL’s locked errcodes.txt maps concrete mechanisms to descendants such as 23001, 23502, 23503, 23505, 23514, and 23P01. The core PostgreSQL 18.6 call scan contains no resolved 23000 report group, so this page records a definition and dispatch boundary rather than inventing a natural SQL reproduction.

Diagnosis {#diagnosis}

Read the server SQLSTATE first, then use constraint_name, table_name, column_name, schema_name, and the primary/detail fields when present. A client that collapses every Class 23 value to 23000 loses the distinction needed to repair a NOT NULL, foreign-key, unique, CHECK, exclusion, or RESTRICT failure.

Response {#response}

Keep the original statement and transaction boundary. Handle the concrete descendant if one is returned; repair the data or schema rule that it identifies, roll back a failed explicit transaction, and retry only after the intended invariant is satisfied. Do not emit RAISE EXCEPTION ... ERRCODE 23000 as if it demonstrated a natural server path.

Source message templates {#messages}

Applicability boundary {#case}

This batch does not construct a natural SQL trigger for 23000; treat it as a source/protocol boundary rather than a copyable reproduction. structured evidence · case export.

Authored evidence IDs: identity, specific-codes, handling. Selected runtime records: —.

Versions {#versions}

The locked catalogue observes the umbrella by 7.4 and in every listed 9.0–18.6 formal snapshot. The absence of a resolved 18.6 core call site is a bounded source observation, not a claim about extensions or future releases.

Related {#related}

See 23001 RESTRICT violation, 23502 NOT NULL violation, 23514 CHECK violation, 23P01 exclusion violation, and 23505 unique violation.

Sources {#sources}

  • src.errcodes.18.6 (SHA-256 6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba)
  • src.calls.REL_18_6 (SHA-256 9ee8a0e81d8f0825c5c1ae45583439859a26e602bdd4ce2f2a62aa278867ccbf)

Compare versions

SQLSTATE evidence and recorded runtime versions

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": ""
}

Source references

Full definition and evidence JSON

Definition sources

center · PostgreSQL 18 · english-manuals:dfb075259b1f05c585b6419eae8555a547c1fb8bcd43ecbfd8603af86c861748

Text language: en · english-manuals:dfb075259b1f05c585b6419eae8555a547c1fb8bcd43ecbfd8603af86c861748