# HV008 — fdw_invalid_column_number

> PostgreSQL SQLSTATE HV008 denotes an invalid foreign-column ordinal. Inspect the wrapper descriptor and local-to-remote column mapping.
---

# HV008 — fdw_invalid_column_number

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

`HV008` identifies an invalid column number (ordinal) in an FDW descriptor or callback. PostgreSQL 18.6 defines it, but its core/contrib call scan found no direct report group or bundled message.

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

| Field | Value |
| --- | --- |
| SQLSTATE | `HV008` |
| Condition | `fdw_invalid_column_number` |
| 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_COLUMN_NUMBER` |
| Aliases | `—` |

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

## Meaning {#meaning}

The wrapper received or produced an ordinal that is outside the descriptor it is using. This is a mapping/descriptor issue, not evidence that a user SQL column name is absent (`HV005`) or malformed (`HV007`).

## Messages and diagnostics {#messages}

No fixed core message is confirmed. Keep the ordinal, descriptor width, local relation identity, callback phase, and wrapper/remote metadata version.

## Diagnosis {#diagnosis}

Compare the target list and `pg_attribute.attnum` values with the wrapper's remote column array. Check dropped columns, projection rewrites, and schema changes between planning and execution. Read the installed wrapper source for the callback that indexes the descriptor.

## Response {#response}

Refresh the foreign-table mapping or correct the wrapper's ordinal translation, then plan the statement again. Do not mask the error by dropping arbitrary columns; the correct repair depends on which descriptor boundary supplied the invalid ordinal.

## Versions {#versions}

`HV008` is observed in every locked formal snapshot beginning at 9.1.0 through 18.6 and in 19 Beta 3. It was not observed in the available pre-9 definition files.

## Related {#related}

[`HV005`](../hv005/) concerns a missing name, [`HV007`](../hv007/) an invalid name, and [`HV006`](../hv006/) invalid type descriptor metadata.

## Sources {#sources}

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