Removed the _conf table functions and change to use cartodb.cdb_conf

This commit is contained in:
Mario de Frutos
2015-11-17 10:39:22 +01:00
parent e8983283da
commit e28aa9a3a2
2 changed files with 1 additions and 39 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/geocoder.
CREATE TABLE IF NOT EXISTS cdb_geocoder_server._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_server._config', '');
CREATE OR REPLACE FUNCTION cdb_geocoder_server._config_set(key text, value JSON)
RETURNS VOID AS $$
BEGIN
PERFORM cdb_geocoder_server._config_remove(key);
EXECUTE 'INSERT INTO cdb_geocoder_server._config (KEY, VALUE) VALUES ($1, $2);' USING key, value;
END
$$ LANGUAGE PLPGSQL VOLATILE;
CREATE OR REPLACE FUNCTION cdb_geocoder_server._config_remove(key text)
RETURNS VOID AS $$
BEGIN
EXECUTE 'DELETE FROM cdb_geocoder_server._config WHERE KEY = $1;' USING key;
END
$$ LANGUAGE PLPGSQL VOLATILE;
CREATE OR REPLACE FUNCTION cdb_geocoder_server._config_get(key text)
RETURNS JSON AS $$
DECLARE
value JSON;
BEGIN
EXECUTE 'SELECT VALUE FROM cdb_geocoder_server._config WHERE KEY = $1;' INTO value USING key;
RETURN value;
END
$$ LANGUAGE PLPGSQL STABLE;

View File

@@ -9,7 +9,7 @@ CREATE TYPE cdb_geocoder_server._redis_conf_params AS (
-- Get the Redis configuration from the _conf table --
CREATE OR REPLACE FUNCTION cdb_geocoder_server._get_redis_conf()
RETURNS cdb_geocoder_server._redis_conf_params AS $$
conf = plpy.execute("SELECT cdb_geocoder_server._config_get('redis_conf') conf")[0]['conf']
conf = plpy.execute("SELECT cartodb.CDB_Conf_GetConf('redis_conf') conf")[0]['conf']
if conf is None:
plpy.error("There is no redis configuration defined")
else: