# HV00B — fdw_invalid_handle

> PostgreSQL SQLSTATE HV00B identifies an invalid handle at an FDW or SQL/MED boundary. The actual handle owner and lifecycle must come from the installed wrapper.
---

# HV00B — fdw_invalid_handle

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

`HV00B` names an invalid FDW handle: a wrapper received a handle that is unknown, closed, or invalid for the current operation. The PostgreSQL 18.6 core/contrib call scan has no resolved direct `HV00B` report group, so the handle type and message are implementation-specific.

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

| Field | Value |
| --- | --- |
| SQLSTATE | `HV00B` |
| Condition | `fdw_invalid_handle` |
| Status | `active` |
| Known present by | `9.1.0` |
| Locked snapshots | `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_FDW_INVALID_HANDLE` |
| Aliases | `—` |

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

## Meaning {#meaning}

SQL/MED uses “handle” for an implementation-owned reference, not a PostgreSQL relation OID or a SQL transaction ID. A wrapper might use one for a remote connection, cursor, reply, or execution object; these are possible examples, not an established emitter path in this batch. The class definition alone does not identify which one.

## Messages and diagnostics {#messages}

No direct 18.6 core/contrib message variant was resolved. Record the wrapper name/version, handle kind and lifetime, callback phase, foreign server/table, and the complete diagnostic. A remote server's connection failure may be a different SQLSTATE.

## Diagnosis {#diagnosis}

Trace creation, transfer, reuse, and close of the handle in the wrapper source. Check whether a scan or modification callback outlived a connection, whether a callback ran after cleanup, and whether the wrapper's ABI matches the server. Do not infer that a NULL SQL value is an invalid handle.

## Response {#response}

Repair the wrapper's handle lifecycle or recreate the wrapper-owned connection/object according to its API. If the wrapper cannot establish whether a write completed, inspect remote logs before repeating it. An unchanged request is unlikely to repair a stale or closed handle.

## Versions {#versions}

`HV00B` is present from 9.1.0 through 18.6 and in 19 Beta 3. The available pre-9 definition scan did not observe it; this is a history boundary, not an exact introduction claim.

## Related {#related}

[`HV00K`](../hv00k/) concerns a reply handle; [`HV009`](../hv009/) concerns invalid null-pointer use; [`HV00N`](../hv00n/) concerns establishing a connection.

## Sources {#sources}

- [`errcodes.txt`](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt#L470) — definition, SHA-256 `6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba`.
- [`fdwapi.h`](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/include/foreign/fdwapi.h#L24-L55) — callback boundary.
- [Structured evidence](../data/evidence/hv00b.json) — bounded source scan.
