2019-05-31 21:29:28 +08:00
|
|
|
---- Make sure '@extschema@' is in database search path
|
2014-05-06 00:48:48 +08:00
|
|
|
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';
|
2014-05-06 00:48:48 +08:00
|
|
|
ELSE
|
2019-05-31 21:29:28 +08:00
|
|
|
var_cur_search_path := var_cur_search_path || ', "@extschema@"';
|
2014-05-06 00:48:48 +08:00
|
|
|
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';
|
2014-05-06 00:48:48 +08:00
|
|
|
END IF;
|
|
|
|
|
|
|
|
-- Reset search_path
|
|
|
|
EXECUTE 'SET search_path = ' || var_cur_search_path;
|
|
|
|
|
|
|
|
END
|
|
|
|
$$ LANGUAGE 'plpgsql';
|