2017-10-18 16:24:50 +08:00
|
|
|
--DO NOT MODIFY THIS FILE, IT IS GENERATED AUTOMATICALLY FROM SOURCES
|
|
|
|
-- Complain if script is sourced in psql, rather than via CREATE EXTENSION
|
2017-12-29 22:28:29 +08:00
|
|
|
\echo Use "ALTER EXTENSION cdb_dataservices_client UPDATE TO '0.23.0'" to load this file. \quit
|
2017-10-18 16:24:50 +08:00
|
|
|
|
|
|
|
-- Make sure we have a sane search path to create/update the extension
|
|
|
|
SET search_path = "$user",cartodb,public,cdb_dataservices_client;
|
2017-12-29 22:28:29 +08:00
|
|
|
|
|
|
|
-- HERE goes your code to upgrade/downgrade
|
2017-10-18 16:24:50 +08:00
|
|
|
|
2018-01-04 19:30:58 +08:00
|
|
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_mapbox_geocode_street_point (searchtext text, city text DEFAULT NULL, state_province text DEFAULT NULL, country text DEFAULT NULL)
|
2017-10-18 16:24:50 +08:00
|
|
|
RETURNS Geometry AS $$
|
|
|
|
DECLARE
|
|
|
|
ret Geometry;
|
|
|
|
username text;
|
|
|
|
orgname text;
|
|
|
|
BEGIN
|
|
|
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
|
|
|
RAISE EXCEPTION 'The api_key must be provided';
|
|
|
|
END IF;
|
|
|
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
|
|
|
-- JSON value stored "" is taken as literal
|
|
|
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
|
|
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
|
|
|
END IF;
|
|
|
|
|
2018-01-04 19:30:58 +08:00
|
|
|
SELECT cdb_dataservices_client._cdb_mapbox_geocode_street_point(username, orgname, searchtext, city, state_province, country) INTO ret; RETURN ret;
|
2017-10-18 16:24:50 +08:00
|
|
|
END;
|
2017-11-30 19:31:36 +08:00
|
|
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER STABLE PARALLEL UNSAFE;
|
2017-10-18 16:24:50 +08:00
|
|
|
|
2018-01-04 19:30:58 +08:00
|
|
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_mapbox_isochrone (source geometry(Geometry, 4326), mode text, range integer[], options text[] DEFAULT ARRAY[]::text[])
|
|
|
|
RETURNS SETOF cdb_dataservices_client.isoline AS $$
|
2017-10-18 16:24:50 +08:00
|
|
|
DECLARE
|
2018-01-04 19:30:58 +08:00
|
|
|
|
2017-10-18 16:24:50 +08:00
|
|
|
username text;
|
|
|
|
orgname text;
|
|
|
|
BEGIN
|
|
|
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
|
|
|
RAISE EXCEPTION 'The api_key must be provided';
|
|
|
|
END IF;
|
|
|
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
|
|
|
-- JSON value stored "" is taken as literal
|
|
|
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
|
|
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
|
|
|
END IF;
|
|
|
|
|
2018-01-04 19:30:58 +08:00
|
|
|
RETURN QUERY SELECT * FROM cdb_dataservices_client._cdb_mapbox_isochrone(username, orgname, source, mode, range, options);
|
2017-10-18 16:24:50 +08:00
|
|
|
END;
|
2017-11-30 19:31:36 +08:00
|
|
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER STABLE PARALLEL UNSAFE;
|
2017-10-18 16:24:50 +08:00
|
|
|
|
2018-01-04 19:30:58 +08:00
|
|
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client.cdb_mapbox_isodistance (source geometry(Geometry, 4326), mode text, range integer[], options text[] DEFAULT ARRAY[]::text[])
|
|
|
|
RETURNS SETOF cdb_dataservices_client.isoline AS $$
|
2017-10-18 16:24:50 +08:00
|
|
|
DECLARE
|
2018-01-04 19:30:58 +08:00
|
|
|
|
2017-10-18 16:24:50 +08:00
|
|
|
username text;
|
|
|
|
orgname text;
|
|
|
|
BEGIN
|
|
|
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
|
|
|
RAISE EXCEPTION 'The api_key must be provided';
|
|
|
|
END IF;
|
|
|
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
|
|
|
-- JSON value stored "" is taken as literal
|
|
|
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
|
|
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
|
|
|
END IF;
|
|
|
|
|
2018-01-04 19:30:58 +08:00
|
|
|
RETURN QUERY SELECT * FROM cdb_dataservices_client._cdb_mapbox_isodistance(username, orgname, source, mode, range, options);
|
2017-10-18 16:24:50 +08:00
|
|
|
END;
|
2017-11-30 19:31:36 +08:00
|
|
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER STABLE PARALLEL UNSAFE;
|
2017-10-18 16:24:50 +08:00
|
|
|
|
2018-01-04 19:30:58 +08:00
|
|
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_mapbox_geocode_street_point_exception_safe (searchtext text, city text DEFAULT NULL, state_province text DEFAULT NULL, country text DEFAULT NULL)
|
2017-10-18 16:24:50 +08:00
|
|
|
RETURNS Geometry AS $$
|
|
|
|
DECLARE
|
|
|
|
ret Geometry;
|
|
|
|
username text;
|
|
|
|
orgname text;
|
2018-01-04 19:30:58 +08:00
|
|
|
_returned_sqlstate TEXT;
|
|
|
|
_message_text TEXT;
|
|
|
|
_pg_exception_context TEXT;
|
2017-10-18 16:24:50 +08:00
|
|
|
BEGIN
|
|
|
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
|
|
|
RAISE EXCEPTION 'The api_key must be provided';
|
|
|
|
END IF;
|
|
|
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
|
|
|
-- JSON value stored "" is taken as literal
|
|
|
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
|
|
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
|
|
|
END IF;
|
|
|
|
|
|
|
|
|
2018-01-04 19:30:58 +08:00
|
|
|
BEGIN
|
|
|
|
SELECT cdb_dataservices_client._cdb_mapbox_geocode_street_point(username, orgname, searchtext, city, state_province, country) INTO ret; RETURN ret;
|
|
|
|
EXCEPTION
|
|
|
|
WHEN OTHERS THEN
|
|
|
|
GET STACKED DIAGNOSTICS _returned_sqlstate = RETURNED_SQLSTATE,
|
|
|
|
_message_text = MESSAGE_TEXT,
|
|
|
|
_pg_exception_context = PG_EXCEPTION_CONTEXT;
|
|
|
|
RAISE WARNING USING ERRCODE = _returned_sqlstate, MESSAGE = _message_text, DETAIL = _pg_exception_context;
|
|
|
|
RETURN ret;
|
|
|
|
END;
|
2017-10-18 16:24:50 +08:00
|
|
|
END;
|
2017-11-30 19:31:36 +08:00
|
|
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER STABLE PARALLEL UNSAFE;
|
2017-10-18 16:24:50 +08:00
|
|
|
|
2018-01-04 19:30:58 +08:00
|
|
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_mapbox_isochrone_exception_safe(source geometry(Geometry, 4326), mode text, range integer[], options text[] DEFAULT ARRAY[]::text[])
|
|
|
|
RETURNS SETOF cdb_dataservices_client.isoline AS $$
|
2017-10-18 16:24:50 +08:00
|
|
|
DECLARE
|
2018-01-04 19:30:58 +08:00
|
|
|
|
2017-10-18 16:24:50 +08:00
|
|
|
username text;
|
|
|
|
orgname text;
|
2018-01-04 19:30:58 +08:00
|
|
|
_returned_sqlstate TEXT;
|
|
|
|
_message_text TEXT;
|
|
|
|
_pg_exception_context TEXT;
|
2017-10-18 16:24:50 +08:00
|
|
|
BEGIN
|
|
|
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
|
|
|
RAISE EXCEPTION 'The api_key must be provided';
|
|
|
|
END IF;
|
|
|
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
|
|
|
-- JSON value stored "" is taken as literal
|
|
|
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
|
|
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
|
|
|
END IF;
|
|
|
|
|
|
|
|
|
2018-01-04 19:30:58 +08:00
|
|
|
BEGIN
|
|
|
|
RETURN QUERY SELECT * FROM cdb_dataservices_client._cdb_mapbox_isochrone(username, orgname, source, mode, range, options);
|
|
|
|
EXCEPTION
|
|
|
|
WHEN OTHERS THEN
|
|
|
|
GET STACKED DIAGNOSTICS _returned_sqlstate = RETURNED_SQLSTATE,
|
|
|
|
_message_text = MESSAGE_TEXT,
|
|
|
|
_pg_exception_context = PG_EXCEPTION_CONTEXT;
|
|
|
|
RAISE WARNING USING ERRCODE = _returned_sqlstate, MESSAGE = _message_text, DETAIL = _pg_exception_context;
|
|
|
|
|
|
|
|
END;
|
2017-10-18 16:24:50 +08:00
|
|
|
END;
|
2017-11-30 19:31:36 +08:00
|
|
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER STABLE PARALLEL UNSAFE;
|
2017-10-18 16:24:50 +08:00
|
|
|
|
2018-01-04 19:30:58 +08:00
|
|
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_mapbox_isodistance_exception_safe(source geometry(Geometry, 4326), mode text, range integer[], options text[] DEFAULT ARRAY[]::text[])
|
|
|
|
RETURNS SETOF cdb_dataservices_client.isoline AS $$
|
2017-10-18 16:24:50 +08:00
|
|
|
DECLARE
|
2018-01-04 19:30:58 +08:00
|
|
|
|
2017-10-18 16:24:50 +08:00
|
|
|
username text;
|
|
|
|
orgname text;
|
2018-01-04 19:30:58 +08:00
|
|
|
_returned_sqlstate TEXT;
|
|
|
|
_message_text TEXT;
|
|
|
|
_pg_exception_context TEXT;
|
2017-10-18 16:24:50 +08:00
|
|
|
BEGIN
|
|
|
|
IF session_user = 'publicuser' OR session_user ~ 'cartodb_publicuser_*' THEN
|
|
|
|
RAISE EXCEPTION 'The api_key must be provided';
|
|
|
|
END IF;
|
|
|
|
SELECT u, o INTO username, orgname FROM cdb_dataservices_client._cdb_entity_config() AS (u text, o text);
|
|
|
|
-- JSON value stored "" is taken as literal
|
|
|
|
IF username IS NULL OR username = '' OR username = '""' THEN
|
|
|
|
RAISE EXCEPTION 'Username is a mandatory argument, check it out';
|
|
|
|
END IF;
|
|
|
|
|
|
|
|
|
2018-01-04 19:30:58 +08:00
|
|
|
BEGIN
|
|
|
|
RETURN QUERY SELECT * FROM cdb_dataservices_client._cdb_mapbox_isodistance(username, orgname, source, mode, range, options);
|
|
|
|
EXCEPTION
|
|
|
|
WHEN OTHERS THEN
|
|
|
|
GET STACKED DIAGNOSTICS _returned_sqlstate = RETURNED_SQLSTATE,
|
|
|
|
_message_text = MESSAGE_TEXT,
|
|
|
|
_pg_exception_context = PG_EXCEPTION_CONTEXT;
|
|
|
|
RAISE WARNING USING ERRCODE = _returned_sqlstate, MESSAGE = _message_text, DETAIL = _pg_exception_context;
|
|
|
|
|
|
|
|
END;
|
2017-10-18 16:24:50 +08:00
|
|
|
END;
|
2017-11-30 19:31:36 +08:00
|
|
|
$$ LANGUAGE 'plpgsql' SECURITY DEFINER STABLE PARALLEL UNSAFE;
|
2017-10-18 16:24:50 +08:00
|
|
|
|
2018-01-04 19:30:58 +08:00
|
|
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_mapbox_geocode_street_point (username text, orgname text, searchtext text, city text DEFAULT NULL, state_province text DEFAULT NULL, country text DEFAULT NULL)
|
2017-10-18 16:24:50 +08:00
|
|
|
RETURNS Geometry AS $$
|
2018-01-04 19:30:58 +08:00
|
|
|
CONNECT cdb_dataservices_client._server_conn_str();
|
|
|
|
|
|
|
|
SELECT cdb_dataservices_server.cdb_mapbox_geocode_street_point (username, orgname, searchtext, city, state_province, country);
|
|
|
|
|
|
|
|
$$ LANGUAGE plproxy VOLATILE PARALLEL UNSAFE;
|
2017-10-18 16:24:50 +08:00
|
|
|
|
2018-01-04 19:30:58 +08:00
|
|
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_mapbox_isochrone (username text, orgname text, source geometry(Geometry, 4326), mode text, range integer[], options text[] DEFAULT ARRAY[]::text[])
|
|
|
|
RETURNS SETOF cdb_dataservices_client.isoline AS $$
|
|
|
|
CONNECT cdb_dataservices_client._server_conn_str();
|
|
|
|
|
|
|
|
SELECT * FROM cdb_dataservices_server.cdb_mapbox_isochrone (username, orgname, source, mode, range, options);
|
|
|
|
|
|
|
|
$$ LANGUAGE plproxy VOLATILE PARALLEL UNSAFE;
|
2017-10-18 16:24:50 +08:00
|
|
|
|
2018-01-04 19:30:58 +08:00
|
|
|
CREATE OR REPLACE FUNCTION cdb_dataservices_client._cdb_mapbox_isodistance (username text, orgname text, source geometry(Geometry, 4326), mode text, range integer[], options text[] DEFAULT ARRAY[]::text[])
|
|
|
|
RETURNS SETOF cdb_dataservices_client.isoline AS $$
|
|
|
|
CONNECT cdb_dataservices_client._server_conn_str();
|
|
|
|
|
|
|
|
SELECT * FROM cdb_dataservices_server.cdb_mapbox_isodistance (username, orgname, source, mode, range, options);
|
|
|
|
|
|
|
|
$$ LANGUAGE plproxy VOLATILE PARALLEL UNSAFE;
|
2017-10-18 16:24:50 +08:00
|
|
|
|
2018-01-04 19:30:58 +08:00
|
|
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_mapbox_geocode_street_point(searchtext text, city text, state_province text, country text) TO publicuser;
|
|
|
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client._cdb_mapbox_geocode_street_point_exception_safe(searchtext text, city text, state_province text, country text ) TO publicuser;
|
2017-12-29 22:28:29 +08:00
|
|
|
|
2018-01-04 19:30:58 +08:00
|
|
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_mapbox_isochrone(source geometry(Geometry, 4326), mode text, range integer[], options text[]) TO publicuser;
|
|
|
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client._cdb_mapbox_isochrone_exception_safe(source geometry(Geometry, 4326), mode text, range integer[], options text[] ) TO publicuser;
|
2017-10-18 16:24:50 +08:00
|
|
|
|
2017-12-29 22:28:29 +08:00
|
|
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client.cdb_mapbox_isodistance(source geometry(Geometry, 4326), mode text, range integer[], options text[]) TO publicuser;
|
|
|
|
GRANT EXECUTE ON FUNCTION cdb_dataservices_client._cdb_mapbox_isodistance_exception_safe(source geometry(Geometry, 4326), mode text, range integer[], options text[] ) TO publicuser;
|