cartodb-postgresql/scripts-available/CDB_Conf.sql

36 lines
1.0 KiB
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 cartodb.CDB_CONF ( PARAM TEXT PRIMARY KEY, CONF TEXT NOT NULL );
EXECUTE format('GRANT SELECT ON cartodb.CDB_CONF TO %s', cartodb.CDB_Organization_Member_Group_Role_Member_Name());
2015-08-14 02:43:17 +08:00
END
$$;
CREATE OR REPLACE
FUNCTION cartodb.CDB_Conf_SetConf(param text, conf text)
2015-08-14 02:43:17 +08:00
RETURNS void AS $$
BEGIN
PERFORM cartodb.CDB_Conf_RemoveConf(param);
EXECUTE 'INSERT INTO cartodb.CDB_CONF (PARAM, CONF) VALUES ($1, $2);' USING param, conf;
2015-08-14 02:43:17 +08:00
END
$$ LANGUAGE PLPGSQL VOLATILE;
CREATE OR REPLACE
FUNCTION cartodb.CDB_Conf_RemoveConf(param text)
2015-08-14 02:43:17 +08:00
RETURNS void AS $$
BEGIN
EXECUTE 'DELETE FROM cartodb.CDB_CONF WHERE PARAM = $1;' USING param;
2015-08-14 02:43:17 +08:00
END
$$ LANGUAGE PLPGSQL VOLATILE;
CREATE OR REPLACE
FUNCTION cartodb.CDB_Conf_GetConf(param text)
2015-08-14 02:43:17 +08:00
RETURNS TEXT AS $$
DECLARE
conf TEXT;
2015-08-14 02:43:17 +08:00
BEGIN
EXECUTE 'SELECT CONF FROM cartodb.CDB_CONF WHERE PARAM = $1;' INTO conf USING param;
RETURN conf;
2015-08-14 02:43:17 +08:00
END
$$ LANGUAGE PLPGSQL STABLE;