2015-11-10 22:28:12 +08:00
|
|
|
--
|
|
|
|
-- Public geocoder API function
|
|
|
|
--
|
|
|
|
-- These are the only ones with permissions to publicuser role
|
|
|
|
-- and should also be the only ones with SECURITY DEFINER
|
|
|
|
|
2015-11-11 23:52:45 +08:00
|
|
|
CREATE OR REPLACE FUNCTION cdb_geocoder_client.geocode_admin0_polygons(country_name text)
|
2015-11-10 22:28:12 +08:00
|
|
|
RETURNS Geometry AS $$
|
|
|
|
DECLARE
|
|
|
|
ret Geometry;
|
|
|
|
BEGIN
|
2015-11-12 00:50:22 +08:00
|
|
|
SELECT cdb_geocoder_client._geocode_admin0_polygons(session_user, txid_current(), country_name) INTO ret;
|
2015-11-10 22:28:12 +08:00
|
|
|
RETURN ret;
|
|
|
|
END;
|
|
|
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
|
|
|
|
|
|
|
|
|
|
|
-- TODO: review all permissions stuff [I'd explicitly grant permissions to the public functions]
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
|
2015-11-12 00:50:22 +08:00
|
|
|
CREATE OR REPLACE FUNCTION cdb_geocoder_client._geocode_admin0_polygons(user_id name, tx_id bigint, country_name text)
|
2015-11-10 22:28:12 +08:00
|
|
|
RETURNS Geometry AS $$
|
2015-11-12 00:50:22 +08:00
|
|
|
CONNECT cdb_geocoder_client._server_conn_str();
|
2015-11-11 23:52:45 +08:00
|
|
|
SELECT cdb_geocoder_server.geocode_admin0_polygons(user_id, tx_id, country_name);
|
2015-11-10 22:28:12 +08:00
|
|
|
$$ LANGUAGE plproxy;
|