HV005
PostgreSQLERRORNotableForeign Data Wrapper ErrorHIGH confidence

FDW column name not found

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
trigger — this will error
-- Foreign table defines column "email" but remote table has "email_address":
SELECT email FROM remote_users;

expected output

ERROR:  column "email" does not exist on foreign server

Fix 1

Use the column_name option to map local to remote column names

WHEN When the local and remote column names differ.

Use the column_name option to map local to remote column names
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 When the remote schema has changed.

Why this works

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

Sources
Official documentation ↗

Class HV — Foreign Data Wrapper Error

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All PostgreSQL errors