Added connection function to get the connection string to the server database
This commit is contained in:
parent
55337efc3a
commit
22239d2da6
16
client/sql/0.0.1/06_geocoder_server_conn.sql
Normal file
16
client/sql/0.0.1/06_geocoder_server_conn.sql
Normal file
@ -0,0 +1,16 @@
|
||||
--
|
||||
-- Geocoder server connection config
|
||||
--
|
||||
-- The purpose of this function is provide to the PL/Proxy functions
|
||||
-- the connection string needed to connect with the server
|
||||
|
||||
CREATE OR REPLACE FUNCTION cdb_geocoder_client._server_conn_str()
|
||||
RETURNS text AS $$
|
||||
DECLARE
|
||||
db_connection_str text;
|
||||
BEGIN
|
||||
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;
|
||||
RETURN db_connection_str;
|
||||
END;
|
||||
$$ LANGUAGE 'plpgsql';
|
@ -7,12 +7,9 @@
|
||||
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 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;
|
||||
SELECT cdb_geocoder_client._geocode_admin0_polygons(session_user, txid_current(), country_name) INTO ret;
|
||||
RETURN ret;
|
||||
END;
|
||||
$$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||
@ -22,9 +19,9 @@ $$ LANGUAGE 'plpgsql' SECURITY DEFINER;
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
CREATE OR REPLACE FUNCTION cdb_geocoder_client._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, country_name text)
|
||||
RETURNS Geometry AS $$
|
||||
-- TODO check if we can move the config to its own function
|
||||
CONNECT db_connection_str;
|
||||
CONNECT cdb_geocoder_client._server_conn_str();
|
||||
SELECT cdb_geocoder_server.geocode_admin0_polygons(user_id, tx_id, country_name);
|
||||
$$ LANGUAGE plproxy;
|
||||
|
Loading…
Reference in New Issue
Block a user