Added schema to client functions and fixed some errors

This commit is contained in:
Mario de Frutos
2015-11-11 16:52:45 +01:00
parent c973cdb0b1
commit 65ffb5d645
2 changed files with 16 additions and 15 deletions

View File

@@ -4,14 +4,15 @@
-- These are the only ones with permissions to publicuser role
-- and should also be the only ones with SECURITY DEFINER
CREATE OR REPLACE FUNCTION geocode_admin0_polygons(country_name text)
CREATE OR REPLACE FUNCTION cdb_geocoder_client.geocode_admin0_polygons(country_name text)
RETURNS Geometry AS $$
DECLARE
db_connection_str text;
ret Geometry;
BEGIN
SELECT _config_get('db_connection_str') INTO db_connection_str;
SELECT _geocode_admin0_polygons(session_user, txid_current(), db_connection_str, country_name) INTO ret;
SELECT cdb_geocoder_client._config_get('db_server_config')->'connection_str' INTO db_connection_str;
SELECT trim(both '"' FROM db_connection_str) INTO db_connection_str;
SELECT cdb_geocoder_client._geocode_admin0_polygons(session_user, txid_current(), db_connection_str, country_name) INTO ret;
RETURN ret;
END;
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
@@ -21,9 +22,9 @@ $$ LANGUAGE 'plpgsql' SECURITY DEFINER;
--------------------------------------------------------------------------------
CREATE OR REPLACE FUNCTION _geocode_admin0_polygons(user_id name, tx_id bigint, db_connection_str text, country_name text)
CREATE OR REPLACE FUNCTION cdb_geocoder_client._geocode_admin0_polygons(user_id name, tx_id bigint, db_connection_str text, country_name text)
RETURNS Geometry AS $$
-- TODO check if we can move the config to its own function
CONNECT db_connection_str;
SELECT geocode_admin0(user_id, tx_id, country_name);
SELECT cdb_geocoder_server.geocode_admin0_polygons(user_id, tx_id, country_name);
$$ LANGUAGE plproxy;