HV004
PostgreSQLERRORNotableForeign Data Wrapper ErrorHIGH confidence

FDW invalid data type

What this means

SQLSTATE HV004 is raised when a foreign data wrapper encounters a data type that it cannot handle when reading data from the foreign data source.

Why it happens
  1. 1The remote data source returns a data type that the FDW cannot map to a Postgres type
  2. 2A column type mismatch between the foreign table definition and the actual remote data
How to reproduce

FDW receiving an unsupported data type from the remote source.

expected output

ERROR:  invalid type specification

Fix

Redefine the foreign table column with a compatible Postgres type

WHEN When the FDW reports an invalid type for a specific column.

Redefine the foreign table column with a compatible Postgres type
ALTER FOREIGN TABLE remote_products ALTER COLUMN price TYPE TEXT;
-- read as TEXT and cast in SQL:
SELECT price::NUMERIC FROM remote_products;

Why this works

Using TEXT or a more flexible type for the foreign table column allows the FDW to transfer the value as a string. Cast to the target type in SQL.

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