# HV009 — fdw_invalid_use_of_null_pointer

> PostgreSQL SQLSTATE HV009 denotes an FDW null-pointer contract violation. Identify the wrapper callback and preserve the failure context.
---

# HV009 — fdw_invalid_use_of_null_pointer

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

`HV009` describes an invalid null-pointer use at the FDW boundary. The PostgreSQL 18.6 core/contrib scan found no direct resolved report group, so no safe SQL reproduction or bundled message is claimed.

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

| Field | Value |
| --- | --- |
| SQLSTATE | `HV009` |
| Condition | `fdw_invalid_use_of_null_pointer` |
| 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_USE_OF_NULL_POINTER` |
| Aliases | `—` |

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

## Meaning {#meaning}

The condition is intended for a wrapper/API contract violation involving a null pointer, such as an absent descriptor, handle, or callback result that the wrapper treats as present. It is not a generic SQL `NULL` value error and cannot be inferred from a nullable column.

## Messages and diagnostics {#messages}

No fixed core message variant was found. Preserve the pointer-owning callback, handle/descriptor identity, wrapper build, and full server log. A crash, `XX000`, or a driver exception may occur instead depending on the implementation.

## Diagnosis {#diagnosis}

Treat this as a wrapper defect or contract mismatch until source proves otherwise. Inspect the callback implementation and ABI/API version, then check whether a remote disconnect or failed allocation created the null state. Do not dereference or “repair” the object from SQL.

## Response {#response}

Stop retrying the same operation while the wrapper defect is present. Preserve logs and isolate the foreign server/table, then upgrade or patch the wrapper after reproducing in a disposable environment. If the process or connection terminated, follow that component's recovery procedure.

## Versions {#versions}

The condition is observed from 9.1.0 through 18.6 and the 19 Beta 3 preview; pre-9 definition scans did not observe it. No implementation introduction version is claimed.

## Related {#related}

[`HV00B`](../hv00b/) is an invalid FDW handle; [`XX000`](../xx000/) is a broader internal-error boundary. A normal SQL null-value condition is in Class 22.

## Sources {#sources}

- [`errcodes.txt`](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt#L475) — 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/hv009.json) — bounded scan and source boundary.
