CREATE FUNCTION nominatim_fdw_handler() RETURNS fdw_handler AS 'MODULE_PATHNAME' LANGUAGE C STRICT; CREATE FUNCTION nominatim_fdw_validator(text[], oid) RETURNS void AS 'MODULE_PATHNAME' LANGUAGE C STRICT; CREATE FUNCTION nominatim_fdw_version() RETURNS text AS 'MODULE_PATHNAME', 'nominatim_fdw_version' LANGUAGE C STABLE PARALLEL SAFE; CREATE TYPE NominatimRecord AS ( osm_id bigint, osm_type text, ref text, class text, display_name text, place_id bigint, place_rank int, address_rank int, lon numeric, lat numeric, boundingbox text, importance double precision, icon text, timestamp timestamptz, attribution text, querystring text, polygon text, exclude_place_ids text, more_url text, extratags jsonb, namedetails jsonb, addressdetails jsonb, entrances jsonb, type text ); CREATE TYPE NominatimReverseGeocode AS ( osm_id bigint, osm_type text, display_name text, ref text, place_id bigint, place_rank int, address_rank int, lon numeric, lat numeric, boundingbox text, icon text, timestamp timestamptz, attribution text, querystring text, polygon text, extratags jsonb, namedetails jsonb, addressdetails jsonb, entrances jsonb ); CREATE FUNCTION nominatim_search( server_name text, q text DEFAULT '', amenity text DEFAULT '', street text DEFAULT '', city text DEFAULT '', county text DEFAULT '', state text DEFAULT '', country text DEFAULT '', postalcode text DEFAULT '', extratags boolean DEFAULT false, addressdetails boolean DEFAULT false, namedetails boolean DEFAULT false, polygon text DEFAULT '', accept_language text DEFAULT '', countrycodes text DEFAULT '', layer text DEFAULT '', featuretype text DEFAULT '', exclude_place_ids text DEFAULT '', viewbox text DEFAULT '', bounded boolean DEFAULT false, polygon_threshold double precision DEFAULT 0.0, email text DEFAULT '', dedupe boolean DEFAULT true, limit_result int DEFAULT 0, entrances boolean DEFAULT false) RETURNS SETOF NominatimRecord AS 'MODULE_PATHNAME', 'nominatim_fdw_search' LANGUAGE C VOLATILE STRICT PARALLEL SAFE; CREATE FUNCTION nominatim_lookup( server_name text, osm_ids text, extratags boolean DEFAULT false, addressdetails boolean DEFAULT true, namedetails boolean DEFAULT false, polygon text DEFAULT '', entrances boolean DEFAULT false, accept_language text DEFAULT '', polygon_threshold double precision DEFAULT 0.0, email text DEFAULT '') RETURNS SETOF NominatimRecord AS 'MODULE_PATHNAME', 'nominatim_fdw_lookup' LANGUAGE C VOLATILE STRICT PARALLEL SAFE; CREATE FUNCTION nominatim_reverse( server_name text, lon double precision DEFAULT 0, lat double precision DEFAULT 0, zoom int DEFAULT -1, layer text DEFAULT '', extratags boolean DEFAULT false, addressdetails boolean DEFAULT true, namedetails boolean DEFAULT false, polygon text DEFAULT '', accept_language text DEFAULT '', entrances boolean DEFAULT false, polygon_threshold double precision DEFAULT 0.0, email text DEFAULT '') RETURNS SETOF NominatimReverseGeocode AS 'MODULE_PATHNAME', 'nominatim_fdw_reverse' LANGUAGE C VOLATILE STRICT PARALLEL SAFE; CREATE FUNCTION nominatim_fdw_settings() RETURNS text AS 'MODULE_PATHNAME', 'nominatim_fdw_settings' LANGUAGE C STABLE STRICT; COMMENT ON FUNCTION nominatim_fdw_settings() IS 'Returns detailed dependency information including optional components'; CREATE VIEW nominatim_fdw_settings AS WITH version_string AS ( SELECT nominatim_fdw_settings() AS v ) SELECT component, version FROM version_string, LATERAL (VALUES ('nominatim_fdw', substring(v from 'nominatim_fdw\s+([^\s,]+)')), ('PostgreSQL', substring(v from 'PostgreSQL\s+([^,]+)')), ('libxml', substring(v from 'libxml\s+([^,]+)')), ('libcurl', substring(v from 'libcurl\s+([^,]+)')), ('ssl', substring(v from ',ssl\s+([^,]+)')), ('zlib', substring(v from ',zlib\s+([^,]+)')), ('libSSH', substring(v from ',libSSH\s+([^,]+)')), ('nghttp2', substring(v from ',nghttp2\s+([^,]+)')), ('compiler', substring(v from 'compiled by\s+([^,]+)')), ('built', substring(v from 'built on\s+([^,]+)')) ) AS components(component, version) WHERE version IS NOT NULL; COMMENT ON VIEW nominatim_fdw_settings IS 'Parse detailed dependency information into component versions'; CREATE FOREIGN DATA WRAPPER nominatim_fdw HANDLER nominatim_fdw_handler VALIDATOR nominatim_fdw_validator;