将client_min_messages设置为特定的ROLE postgres [英] SET client_min_messages to specific ROLE postgres

查看:402
本文介绍了将client_min_messages设置为特定的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.

总结一下,我做到了:

  1. 以postgres角色登录.
  2. 检查client_min_messages(通知)和log_min_messages(警告)的默认值.
  3. ALTER ROLE ANNE SET client_min_messages =错误;
  4. ALTER ROLE ANNE SET log_min_messages =恐慌;
  5. 选择pg_reload_conf();
  6. 注销postgres.
  7. 登录anne.
  8. 检查SELECT current_setting('client_min_messages'),并返回NOTICE(默认值).
  9. 检查SELECT current_setting('log_min_messages'),并返回panic(非默认值).
  10. 测试以下代码
  1. Login with postgres role.
  2. check default values of client_min_messages(notice) and log_min_messages(warning).
  3. ALTER ROLE anne SET client_min_messages = error;
  4. ALTER ROLE anne SET log_min_messages = panic;
  5. SELECT pg_reload_conf();
  6. Logout postgres.
  7. Login anne.
  8. check SELECT current_setting('client_min_messages'), returning NOTICE(default value).
  9. check SELECT current_setting('log_min_messages'), returning panic(non default value).
  10. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆