SET client_min_messages to specific ROLE postgres

╄→гoц情女王★ 提交于 2020-04-17 19:01:11

问题


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.

To summarize I did:

  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 $$;

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?

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).


回答1:


The method should work. It worked for me.

Do you have any environment variables (like PGOPTIONS) set or explicit call out of the set client_min_messages command in the session?



来源:https://stackoverflow.com/questions/61256250/set-client-min-messages-to-specific-role-postgres

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!