# 0Z000 — diagnostics_exception

> Source-bounded reference for PostgreSQL SQLSTATE 0Z000.
---

# 0Z000

## At a glance {#at-a-glance}

SQLSTATE 0Z000 is the Diagnostics Exception category. In PostgreSQL's fixed source, the concrete PL/pgSQL path is the member 0Z002; the category row itself is not a separate report group. Use 0Z000 to classify an observed diagnostics member, then keep the member code and its message for diagnosis.

<!-- BEGIN SQLSTATE FACTS: generated by scripts/generate.py; do not edit -->

| Field | Value |
| --- | --- |
| SQLSTATE | `0Z000` |
| Condition | `diagnostics_exception` |
| Status | `active` |
| Known present by | `9.2.0` |
| Locked snapshots | `9.2.24, 9.3.25, 9.4.26, 9.5.25, 9.6.24, 10.23, 11.22, 12.22, 13.23, 14.24, 15.19, 16.15, 17.11, 18.6, 19beta3` |
| Macros | `ERRCODE_DIAGNOSTICS_EXCEPTION` |
| Aliases | `—` |

<!-- source facts: data/errcodes/0Z000.json -->
<!-- END SQLSTATE FACTS -->

## Meaning {#meaning}

The class covers errors raised while accessing diagnostic state. The resolved member path in `pl_exec.c` reports 0Z002 when `GET STACKED DIAGNOSTICS` or parameterless `RAISE` is used outside an active exception handler. That member evidence explains one PostgreSQL path; it does not make every diagnostics API failure a 0Z000 emission.

## Messages {#messages}

No fixed PostgreSQL message variant was adopted for this condition because the bounded scan did not resolve a native emitting call.

## Diagnosis {#diagnosis}

Read the member code and message first. For 0Z002, inspect whether the statement ran inside the `EXCEPTION` handler that owns the stacked error; ordinary function control flow and a handler’s scope matter more than the class name. If another member or producer is present, follow that component’s source and preserve its diagnostic fields.

## Response {#response}

Place `GET STACKED DIAGNOSTICS` and parameterless `RAISE` inside the active PL/pgSQL exception handler they depend on. If the intended behavior is to raise a new error outside a handler, supply an explicit condition/message instead of trying to re-use stacked state. Preserve the member error and do not retry a failed routine merely because it belongs to class 0Z.

## Versions {#versions}

The locked catalogue places this condition at least by PostgreSQL 9.2.0. The release definitions cover the published snapshots listed in the facts block; source-path status is limited to the fixed PostgreSQL 18.6 context cited below.

## Related {#related}

[`0Z002`](../0z002/), [`P0001`](../p0001/)

## Sources {#sources}

The fixed [errcodes definition](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt#L141) establishes the class. The concrete member paths are [GET STACKED DIAGNOSTICS](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/pl/plpgsql/src/pl_exec.c#L2421-L2423) and [parameterless RAISE](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/pl/plpgsql/src/pl_exec.c#L3747-L3749); the [PL/pgSQL error-trapping documentation](https://www.postgresql.org/docs/18/plpgsql-control-structures.html#PLPGSQL-ERROR-TRAPPING) defines the handler boundary. See the structured [evidence record](../data/evidence/0z000.json) for fixed source paths, scan scope, and unresolved runtime boundaries.
