postgresql 尽管之前有“SET client_min_messages TO WARNING”,但 INFO 输出

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21238209/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 01:16:39  来源:igfitidea点击:

INFO output despite "SET client_min_messages TO WARNING" just before

postgresqlloggingsession-variableserror-loggingpostgresql-9.0

提问by Kev

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:

CentOS 6.5 上的 postgresql-9.0.15。我有一个输出 INFO 消息的 plperlu 函数。我想在测试期间抑制它(使用 psql,其行为也如下所示),但我什至无法从 pgAdminIII(win2003 为 1.18.1)查询窗口中执行此操作:

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.

我运行它并查看“消息”选项卡,那里是我的 INFO 消息。

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

(这可能类似于How to suppress INFO messages when running psql scripts,但我不想禁用整个会话的 INFO 消息,只禁用其中的一部分,然后将最小值设置回 NOTICE。)

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

上面的代码片段我做错了什么?client_min_messages 是否不适用于 pl/perlu 函数?

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

更新:经过进一步调查,即使使用 plpgsql 函数,而不仅仅是 plperlu 函数,它似乎也会发生:

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?

我在 pgAdminIII 查询窗口中运行上面的代码片段,“这不应该出现”出现在消息选项卡中。奎?

Update 2: I also tried log_min_messagesjust in case. Same behaviour.

更新 2:我也试过log_min_messages以防万一。同样的行为。

回答by Kev

I asked on the postgresql-general mailing list and received an informative answer: what distinguishes INFOfrom NOTICEis that INFOdoes not have a level: it's intended to always go through, no matter what client_min_messagesor 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 NOTICEfrom my function.

我问PostgreSQL的-general邮件列表上,并获得了翔实的答案:什么区别INFONOTICEINFO不具备的水平:它打算总是通过,不管是什么client_min_messages或其他任何设置为,从功能,你会特别要求用于信息输出。所以就我而言,适当的做法是仅从NOTICE我的函数中输出。