plpgsql:提升通知输出仅在 pgAdmin 中显示

jNe*_*ess 3 postgresql plpgsql

PostgreSQL 9.4。我有一个功能

CREATE OR REPLACE FUNCTION test(source_ text)
  RETURNS text AS
$BODY$
  DECLARE
  BEGIN
   raise debug '%s', source_;
   return source_ || ' processed';
  END
  $BODY$
  LANGUAGE plpgsql STABLE
  COST 100;
ALTER FUNCTION test()
  OWNER TO test;

select * from test('input');
Run Code Online (Sandbox Code Playgroud)

我只能从 pgAmin 看到通知,但从 ide 或 toad(以及其他一些)db 客户端看不到任何通知。如何打开“raise notice”的输出,或者有其他方法可以获取调试信息?

更新

我找到了一个解决方法:tail -F 用于日志文件并在 postgresql.conf 中设置 log_min_messages

Jay*_*nek 5

您需要调整client_min_messages,例如:

set client_min_messages = 'debug';
Run Code Online (Sandbox Code Playgroud)

有关更多信息,请参阅http://www.postgresql.org/docs/9.1/static/runtime-config-logging.html#GUC-CLIENT-MIN-MESSAGES

test=# create or replace function test() returns int as $$
begin
  raise debug 'foo';
  return 1;
end
$$ language plpgsql immutable;
CREATE FUNCTION
test=# select test();
 test 
------
    1
(1 row)

test=# set client_min_messages = 'debug';
SET
test=# select test();
DEBUG:  foo
 test 
------
    1
(1 row)

test=# 
Run Code Online (Sandbox Code Playgroud)