# 38000 — external_routine_exception

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

# 38000

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

Class 38 is broad. Fixed PostgreSQL 18.6 paths include external command failures in `COPY ... PROGRAM` and `basebackup_to_shell`, UUID library failures, and exceptions propagated from PL/Perl, PL/Python, and PL/Tcl. These are separate implementations under one category.

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

| Field | Value |
| --- | --- |
| SQLSTATE | `38000` |
| Condition | `external_routine_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_EXTERNAL_ROUTINE_EXCEPTION` |
| Aliases | `—` |

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

## Meaning {#meaning}

Representative messages include `program "%s" failed` and `shell command "%s" failed`, each with an internal wait-status detail; `OSSP uuid library failure: %s`, `OSSP uuid library failure: error code %d`, `uuid library failure: %d`, and the UUID version-mismatch message; PL/Perl reports such as `didn't get a return item from function`, PL/Python forwards `%s` with optional detail/context/hint, and PL/Tcl reports `could not parse function return value: %s` or a context-bearing `%s`. Keep the dynamic fields and the actual producer; this category has no single fixed message.

## Messages {#messages}

Representative messages include `program "%s" failed` and `shell command "%s" failed`, each with an internal wait-status detail; `OSSP uuid library failure: %s`, `OSSP uuid library failure: error code %d`, `uuid library failure: %d`, and the UUID version-mismatch message; PL/Perl reports such as `didn't get a return item from function`, PL/Python forwards `%s` with optional detail/context/hint, and PL/Tcl reports `could not parse function return value: %s` or a context-bearing `%s`. Keep the dynamic fields and the actual producer; this category has no single fixed message.

## Diagnosis {#diagnosis}

Use the message and context to identify the external boundary: program path and wait result, UUID library operation, or PL language and routine. Inspect the relevant server configuration and handler logs, preserving dynamic `%s` values and any internal detail.

## Response {#response}

Repair the named external command, library, or language routine and verify that boundary independently. A failed external action may have side effects; do not replay it until completion and idempotency are known.

## Versions {#versions}

The locked catalogue places this condition at least by PostgreSQL 7.4. The facts block lists the published snapshots; source-path status is limited to the fixed PostgreSQL 18.6 evidence below.

## Related {#related}

[`38001`](../38001/), [`2F000`](../2f000/)

## Sources {#sources}

Read the fixed [basebackup_to_shell.c](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/contrib/basebackup_to_shell/basebackup_to_shell.c#L239-L243), [copyto.c](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/commands/copyto.c#L575-L579), [uuid-ossp.c](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/contrib/uuid-ossp/uuid-ossp.c#L130-L136), [plperl.c](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/pl/plperl/plperl.c#L2250-L2264), and [pltcl.c](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/pl/tcl/pltcl.c#L1036-L1039) paths alongside the structured [evidence record](../data/evidence/38000.json).
