# 09000 — triggered_action_exception

> Source-backed reference for PostgreSQL SQLSTATE 09000.
---

# 09000

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

SQLSTATE 09000 is an ERROR-level triggered-action condition. In the fixed PostgreSQL 18.6 scan, resolved report paths are in `contrib/spi` trigger functions: they validate trigger arguments, target-column types, referenced tuples, and SPI return codes. The code is therefore tied to those installed trigger functions and their table/trigger configuration; it is not a label for every trigger failure.

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

| Field | Value |
| --- | --- |
| SQLSTATE | `09000` |
| Condition | `triggered_action_exception` |
| Status | `active` |
| Known present by | `7.4` |
| Locked snapshots | `9.0.23, 9.1.24, 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_TRIGGERED_ACTION_EXCEPTION` |
| Aliases | `—` |

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

## Meaning {#meaning}

The confirmed paths include `autoinc.c`, `insert_username.c`, `moddatetime.c`, and `refint.c`. Their message variants include `"%s" has no attribute "%s"`, `attribute "%s" of "%s" must be type INT4`, `... TEXT`, or `... TIMESTAMP or TIMESTAMPTZ`. Referential-integrity support also reports `tuple references non-existent key` with detail `Trigger "%s" found tuple referencing non-existent key in "%s".`, can report `SPI_execp returned %d`, and can report `"%s": tuple is referenced in "%s"` for a restrictive action. These formats contain relation, argument, attribute, trigger, and return-code values supplied by the failing path.

## Messages {#messages}

The confirmed paths include `autoinc.c`, `insert_username.c`, `moddatetime.c`, and `refint.c`. Their message variants include `"%s" has no attribute "%s"`, `attribute "%s" of "%s" must be type INT4`, `... TEXT`, or `... TIMESTAMP or TIMESTAMPTZ`. Referential-integrity support also reports `tuple references non-existent key` with detail `Trigger "%s" found tuple referencing non-existent key in "%s".`, can report `SPI_execp returned %d`, and can report `"%s": tuple is referenced in "%s"` for a restrictive action. These formats contain relation, argument, attribute, trigger, and return-code values supplied by the failing path.

## Diagnosis {#diagnosis}

First identify the installed trigger function and operation phase, then compare the relation and trigger arguments with the function's documented contract. For an attribute/type message, inspect the named column and its type; for the `refint` variants, inspect the trigger name, referenced relation, and the tuple or key relationship. For `SPI_execp returned %d`, preserve the numeric return code and inspect the SPI call that returned it. The fixed scan does not establish a single message for all 09000 reports.

## Response {#response}

Correct the trigger definition, argument list, column type, referenced key, or SPI-side failure identified by the message, then rerun the triggering operation after verifying the change. Do not repair this by blindly replaying a write: a trigger may have performed work before the error, and the correct boundary depends on the surrounding transaction. If the function is supplied by an extension or local code, inspect that implementation and its version before changing application retry behavior.

## Versions {#versions}

The locked catalogue places this condition at least by PostgreSQL 7.4. 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}

[`0A000`](../0a000/), [`2F000`](../2f000/)

## Sources {#sources}

[autoinc.c](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/contrib/spi/autoinc.c#L74-L90), [insert_username.c](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/contrib/spi/insert_username.c#L74-L82), [moddatetime.c](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/contrib/spi/moddatetime.c#L95-L120), and [refint.c](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/contrib/spi/refint.c#L181-L184) and its [referential-restriction branch](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/contrib/spi/refint.c#L504-L516) show the fixed emitters; the [SPI trigger documentation](https://www.postgresql.org/docs/18/spi.html) describes the extension interface. See the structured [evidence record](../data/evidence/09000.json) for fixed source paths, scan scope, and unresolved runtime boundaries.
