PG
PRO
HV005ERRORTier 2 — Caution✅ HIGH confidence

FDW column name not found

Category: Foreign Data Wrapper ErrorVersions: All Postgres versions (with FDW extension)

What this means

SQLSTATE HV005 is raised when a foreign data wrapper cannot find a column name in the descriptor returned by the remote data source — the local foreign table definition references a column that does not exist in the remote table.

Why it happens

  1. 1The foreign table definition includes a column name that does not exist in the remote table or file
  2. 2Remote table schema changed and a column was renamed or dropped

How to reproduce

Foreign table referencing a non-existent remote column.

trigger — this will ERROR
-- Foreign table defines column "email" but remote table has "email_address":
SELECT email FROM remote_users;
ERROR: column "email" does not exist on foreign server

Fix 1: Use the column_name option to map local to remote column names

When the local and remote column names differ.

fix
ALTER FOREIGN TABLE remote_users
  ALTER COLUMN email OPTIONS (SET column_name 'email_address');

Why this works

The column_name option maps the local foreign table column name to the actual column name on the remote server.

Fix 2: Recreate the foreign table with the correct column names

When the remote schema has changed.

fix

Why this works

Drop and recreate the foreign table using IMPORT FOREIGN SCHEMA or manually with the current remote column names.

Sources

📚 Official docs: https://www.postgresql.org/docs/current/errcodes-appendix.html

🔧 Source ref: Class HV — Foreign Data Wrapper Error

Confidence assessment

✅ HIGH confidence

Standard SQLSTATE for FDW column name mapping errors. Stable across versions.

See also

📄 Reference pages

postgres_fdwIMPORT FOREIGN SCHEMAcolumn_name option
⚙️ This error reference was generated with AI assistance and reviewed for accuracy. Examples are provided to illustrate common scenarios and may not cover every case. Always test fixes in a development environment before applying to production. Spotted an error? Suggest a correction →