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
|
2015-08-14 19:55:52 +08:00
|
|
|
CREATE TABLE IF NOT EXISTS cartodb.CDB_CONF ( PARAM TEXT PRIMARY KEY, CONF TEXT NOT NULL );
|
2015-08-14 21:28:19 +08:00
|
|
|
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
|
2015-08-14 19:55:52 +08:00
|
|
|
FUNCTION cartodb.CDB_Conf_SetConf(param text, conf text)
|
2015-08-14 02:43:17 +08:00
|
|
|
RETURNS void AS $$
|
|
|
|
BEGIN
|
2015-08-14 19:55:52 +08:00
|
|
|
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
|
2015-08-14 19:55:52 +08:00
|
|
|
FUNCTION cartodb.CDB_Conf_RemoveConf(param text)
|
2015-08-14 02:43:17 +08:00
|
|
|
RETURNS void AS $$
|
|
|
|
BEGIN
|
2015-08-14 19:55:52 +08:00
|
|
|
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
|
2015-08-14 19:55:52 +08:00
|
|
|
FUNCTION cartodb.CDB_Conf_GetConf(param text)
|
2015-08-14 02:43:17 +08:00
|
|
|
RETURNS TEXT AS $$
|
|
|
|
DECLARE
|
2015-08-14 19:55:52 +08:00
|
|
|
conf TEXT;
|
2015-08-14 02:43:17 +08:00
|
|
|
BEGIN
|
2015-08-14 19:55:52 +08:00
|
|
|
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;
|