cartodb-postgresql/scripts-available/CDB_Conf.sql

35 lines
910 B
MySQL
Raw Normal View History

2015-08-14 16:12:10 +08:00
-- This will trigger NOTICE if CDB_CONF already exists
2015-08-14 02:43:17 +08:00
DO LANGUAGE 'plpgsql' $$
BEGIN
CREATE TABLE IF NOT EXISTS CDB_CONF ( PARAM TEXT PRIMARY KEY, VALUE TEXT NOT NULL );
END
$$;
CREATE OR REPLACE
FUNCTION cartodb.CDB_Conf_SetParam(param text, value text)
RETURNS void AS $$
BEGIN
PERFORM cartodb.CDB_Conf_RemoveParam(param);
EXECUTE 'INSERT INTO CDB_CONF (PARAM, VALUE) VALUES ($1, $2);' USING param, value;
END
$$ LANGUAGE PLPGSQL VOLATILE;
CREATE OR REPLACE
FUNCTION cartodb.CDB_Conf_RemoveParam(param text)
RETURNS void AS $$
BEGIN
EXECUTE 'DELETE FROM CDB_CONF WHERE PARAM = $1;' USING param;
END
$$ LANGUAGE PLPGSQL VOLATILE;
CREATE OR REPLACE
FUNCTION cartodb.CDB_Conf_GetParam(param text)
RETURNS TEXT AS $$
DECLARE
value TEXT;
BEGIN
EXECUTE 'SELECT VALUE FROM CDB_CONF WHERE PARAM = $1;' INTO value USING param;
RETURN value;
END
$$ LANGUAGE PLPGSQL STABLE;