将client_min_messages设置为特定的ROLE postgres [英] SET client_min_messages to specific ROLE postgres
问题描述
您好,我试图使用postgres用户将client_min_messages =错误设置为某个角色,但是当我登录该角色时,我检查了current_setting('client_min_messages')并得到了默认值(通知).香港专业教育学院已经尝试过重新启动配置,还做了一些测试.
Hi Im trying to set the client_min_messages = error to a role using the postgres user, but when I login in the role I check current_setting('client_min_messages') and I get DEFAULT VALUE (notice). Ive already tried restarting config and also done some tests.
总结一下,我做到了:
- 以postgres角色登录.
- 检查client_min_messages(通知)和log_min_messages(警告)的默认值.
- ALTER ROLE ANNE SET client_min_messages =错误;
- ALTER ROLE ANNE SET log_min_messages =恐慌;
- 选择pg_reload_conf();
- 注销postgres.
- 登录anne.
- 检查SELECT current_setting('client_min_messages'),并返回NOTICE(默认值).
- 检查SELECT current_setting('log_min_messages'),并返回panic(非默认值).
- 测试以下代码
- Login with postgres role.
- check default values of client_min_messages(notice) and log_min_messages(warning).
- ALTER ROLE anne SET client_min_messages = error;
- ALTER ROLE anne SET log_min_messages = panic;
- SELECT pg_reload_conf();
- Logout postgres.
- Login anne.
- check SELECT current_setting('client_min_messages'), returning NOTICE(default value).
- check SELECT current_setting('log_min_messages'), returning panic(non default value).
- Test the code below
begin;
do $$
begin
raise info ' client_min_messages: %',current_setting('client_min_messages'); -- i get "notice"
raise debug ' time : %', NOW();
raise notice ' time : %', NOW();
raise warning ' time : %', NOW();
end $$;
我的意思是,我每次与用户登录时都必须设置client_min_messages吗?因此,Alter Role/User SET client_min_messages没用吗?
I mean, I have to set client_min_messages every time I log with an user? So the Alter Role/User SET client_min_messages is useless?
我尝试将login_min_messages更改为特定角色,当我以该角色登录时,配置仍然可以(不是默认值).
I've tried changing login_min_messages to an specific role and when I login with the role the configuration remains ok(not default value).
推荐答案
该方法应该有效.它对我有用.
The method should work. It worked for me.
您是否在会话中设置了任何环境变量(例如PGOPTIONS)或通过set client_min_messages
命令进行了显式调用?
Do you have any environment variables (like PGOPTIONS) set or explicit call out of the set client_min_messages
command in the session?
这篇关于将client_min_messages设置为特定的ROLE postgres的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!