INFO output despite “SET client_min_messages TO WARNING” just before

本小妞迷上赌 提交于 2019-12-19 05:59:45

问题


postgresql-9.0.15 on CentOS 6.5. I have a plperlu function that outputs an INFO message. I want to suppress it during testing (using psql, which also behaves as below), but I can't even seem to do it from a pgAdminIII (1.18.1 for win2003) query window:

SET client_min_messages TO WARNING;
select my_info_outputting_function('lalala')

I run that and look in the "messages" tab, and there's my INFO message.

(This may appear similar to How to suppress INFO messages when running psql scripts , but I don't want to disable INFO messages for my whole session, just part of it and then set the minimum back to NOTICE.)

What am I doing wrong with the above code snippet? Does client_min_messages not apply to pl/perlu functions?

UPDATE: upon further investigation, it seems to happen even with plpgsql functions, not just plperlu functions:

create or replace function my_info_outputting_function() returns void as $$
begin
    raise INFO 'this should not appear...';
    return;
end;
$$ language plpgsql;
SET client_min_messages TO WARNING;
select my_info_outputting_function();

I run the above snippet in a pgAdminIII query window and "this should not appear" appears in the messages tab. Quoi?

Update 2: I also tried log_min_messages just in case. Same behaviour.


回答1:


I asked on the postgresql-general mailing list and received an informative answer: what distinguishes INFO from NOTICE is that INFO does not have a level: it's intended to always go through, no matter what client_min_messages or anything else is set to, from functions that you would call specifically for INFO output. So in my case, the appropriate thing is to output only NOTICE from my function.



来源:https://stackoverflow.com/questions/21238209/info-output-despite-set-client-min-messages-to-warning-just-before

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