Skip to content

HV004 — fdw_invalid_data_type

PostgreSQL SQLSTATE HV004 denotes a foreign-data-wrapper data type mismatch. Confirm the wrapper’s type mapping and the local foreign-table definition.

HV004 — fdw_invalid_data_type

At a glance

HV004 is the SQL/MED condition for a foreign-data-wrapper data type that cannot be used for the requested operation. The 18.6 core/contrib call scan found no resolved direct HV004 report group, so this page does not claim a particular bundled message or SQL trigger.

Field Value
SQLSTATE HV004
Condition fdw_invalid_data_type
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_DATA_TYPE
Aliases

Meaning and scope

The condition belongs to the FDW callback boundary: a wrapper may reject a local column type, a remote type mapping, or a value conversion. PostgreSQL’s FDW documentation notes that a wrapper may raise an error for a data-type mismatch; it does not prescribe one universal mapping or message.

Messages and diagnostics

No fixed 18.6 message variant was resolved for this code. Keep the wrapper’s M, D, H, source file/function, local column type, remote type, and operation. A remote server’s type error must remain distinguishable from the wrapper’s local SQLSTATE.

Diagnosis

Identify the foreign table column and conversion direction, then inspect the wrapper’s validator, deparser, and tuple conversion code at its pinned version. Compare the local catalog type, collation/typmod where relevant, and the remote type metadata. A generic cast failure or 22xxx value error is not evidence for HV004.

Response

Use a supported type mapping or alter the foreign-table definition after checking data compatibility. If conversion is implemented by an external wrapper, upgrade or configure that wrapper only after checking its compatibility contract. Do not retry an unchanged plan; a data-type mismatch is deterministic for the same metadata.

Versions

The catalogue observes HV004 from 9.1.0 through 18.6 and 19 Beta 3. The available pre-9 definition scan did not observe it; no exact introduction version is claimed.

Compare HV006 for inconsistent type descriptors and HV007 for an invalid column name. 42804 is a core datatype mismatch and has a different ownership boundary.

Sources