# HV00Q — fdw_schema_not_found

> PostgreSQL SQLSTATE HV00Q reports that postgres_fdw cannot find the requested remote schema during IMPORT FOREIGN SCHEMA.
---

# HV00Q — fdw_schema_not_found

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

`HV00Q` is a concrete `postgres_fdw` import error. Its remote connection runs an exact `pg_catalog.pg_namespace` lookup for the requested `nspname`; when the result count is not exactly one, the wrapper reports the remote schema by name.

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

| Field | Value |
| --- | --- |
| SQLSTATE | `HV00Q` |
| Condition | `fdw_schema_not_found` |
| 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_SCHEMA_NOT_FOUND` |
| Aliases | `—` |

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

## Meaning and message {#meaning}

In `postgres_fdw.c:5515-5526`, the import path sends `SELECT 1 FROM pg_catalog.pg_namespace WHERE nspname = ...` on the mapped remote connection, checks `PQntuples(res) != 1`, and raises `ERROR: schema "%s" is not present on foreign server "%s"`. The requested remote schema and server name are dynamic fields. The fixed query does not use the local `search_path`; a connection/query failure is handled earlier, while later remote privileges are a separate import concern.

## Diagnosis {#diagnosis}

Check the `IMPORT FOREIGN SCHEMA` source name, remote database, mapped user, and the exact `postgres_fdw` server options. Confirm the mapped remote connection can run the fixed `pg_catalog.pg_namespace` lookup for the exact name; do not diagnose this branch from the local `search_path`. Distinguish a zero-or-unexpected-row result from a connection/query error reported earlier, and check remote schema/table privileges separately when the import proceeds.

## Response {#response}

Use the remote schema's exact name, create it remotely if appropriate, or import from the correct foreign server/database. In autocommit, rerun only after the remote catalog state or mapping is corrected. Inside an explicit transaction, an `ERROR` leaves the local transaction failed; issue `ROLLBACK`, or `ROLLBACK TO` a previously established and still usable `SAVEPOINT`, before retrying the corrected import. Do not replay the command inside an `INERROR` transaction.

## Messages and diagnostics {#messages}

The fixed call group is severity `ERROR`, primary message `schema "%s" is not present on foreign server "%s"`, with no detail or hint. Keep the remote schema/server values and wrapper version.

## Versions {#versions}

`HV00Q` is present from 9.1.0 through 18.6 and 19 Beta 3. Older wording or catalog-query details may vary; the 18.6 path is fixed to commit `724edf9bde9d356724ad384a2e196edc3c9f80f7`.

## Related {#related}

[`HV00P`](../hv00p/) means the wrapper lacks schema-import support; [`3D000`](../3d000/) is a local database-not-found code; [`HV00D`](../hv00d/) concerns invalid wrapper options.

## Sources {#sources}

- [`errcodes.txt`](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/src/backend/utils/errcodes.txt#L481) — definition, SHA-256 `6e8de346643ba84aa3c9c6a73360acfc7b2dfb89162c06c08ce9bf5bcd5bbcba`.
- [`postgres_fdw.c`](https://github.com/postgres/postgres/blob/724edf9bde9d356724ad384a2e196edc3c9f80f7/contrib/postgres_fdw/postgres_fdw.c#L5515-L5526) — remote `pg_namespace` query, result check, and message.
- [Transaction and savepoint recovery](https://www.postgresql.org/docs/18/tutorial-transactions.html) — the explicit-transaction recovery boundary; fixed `xact.sgml` SHA-256 `b48fbe8bd02ce3d1181a350c88c8baa6e11c73edc90a936e77b180daef328c5c`.
- [Structured evidence](../data/evidence/hv00q.json) — source path and message grouping.
