cartodb-postgresql/scripts-available/CDB_SearchPath.sql

25 lines
729 B
MySQL
Raw Normal View History

2019-05-31 21:29:28 +08:00
---- Make sure '@extschema@' is in database search path
DO
$$
DECLARE
var_result text;
var_cur_search_path text;
BEGIN
SELECT reset_val INTO var_cur_search_path
FROM pg_settings WHERE name = 'search_path';
2019-05-31 21:29:28 +08:00
IF var_cur_search_path LIKE '%@extschema@%' THEN
RAISE DEBUG '"@extschema@" already in database search_path';
ELSE
2019-05-31 21:29:28 +08:00
var_cur_search_path := var_cur_search_path || ', "@extschema@"';
EXECUTE 'ALTER DATABASE ' || quote_ident(current_database()) ||
' SET search_path = ' || var_cur_search_path;
2019-05-31 21:29:28 +08:00
RAISE DEBUG '"@extschema@" has been added to end of database search_path';
END IF;
-- Reset search_path
EXECUTE 'SET search_path = ' || var_cur_search_path;
END
$$ LANGUAGE 'plpgsql';