Fixing conflicts

This commit is contained in:
Carla Iriberri
2015-11-17 12:35:07 +01:00
6 changed files with 19 additions and 45 deletions

View File

@@ -1,38 +0,0 @@
--
-- This extension has its own table for configurations.
--
-- The table and the function are considered to be private and therefore
-- no permissions are granted for any other user but the creator.
CREATE TABLE IF NOT EXISTS cdb_geocoder_client._config ( KEY TEXT PRIMARY KEY, VALUE JSON NOT NULL );
-- Needed to dump config in backups
-- This can only be called from an SQL script executed by CREATE EXTENSION
SELECT pg_catalog.pg_extension_config_dump('cdb_geocoder_client._config', '');
CREATE OR REPLACE FUNCTION cdb_geocoder_client._config_set(key text, value JSON)
RETURNS VOID AS $$
BEGIN
PERFORM cdb_geocoder_client._config_remove(key);
EXECUTE 'INSERT INTO cdb_geocoder_client._config (KEY, VALUE) VALUES ($1, $2);' USING key, value;
END
$$ LANGUAGE PLPGSQL VOLATILE;
CREATE OR REPLACE FUNCTION cdb_geocoder_client._config_remove(key text)
RETURNS VOID AS $$
BEGIN
EXECUTE 'DELETE FROM cdb_geocoder_client._config WHERE KEY = $1;' USING key;
END
$$ LANGUAGE PLPGSQL VOLATILE;
CREATE OR REPLACE FUNCTION cdb_geocoder_client._config_get(key text)
RETURNS JSON AS $$
DECLARE
value JSON;
BEGIN
EXECUTE 'SELECT VALUE FROM cdb_geocoder_client._config WHERE KEY = $1;' INTO value USING key;
RETURN value;
END
$$ LANGUAGE PLPGSQL STABLE;

View File

@@ -9,8 +9,8 @@ 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 cartodb.cdb_conf_getconf('geocoder_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';
$$ LANGUAGE 'plpgsql';

View File

@@ -1,12 +1,15 @@
-- Install dependencies
CREATE EXTENSION postgis;
CREATE EXTENSION schema_triggers;
CREATE EXTENSION plpythonu;
CREATE EXTENSION cartodb;
CREATE EXTENSION plproxy;
-- Install the extension
CREATE EXTENSION cdb_geocoder_client;
-- Mock the server connection to point to this very test db
SELECT cdb_geocoder_client._config_set('db_server_config', '{"connection_str": "dbname=contrib_regression host=127.0.0.1 user=postgres"}');
SELECT cartodb.cdb_conf_setconf('geocoder_server_config', '{"connection_str": "dbname=contrib_regression host=127.0.0.1 user=postgres"}');
-- Mock the server schema
CREATE SCHEMA cdb_geocoder_server;