plpgsql: raise notice output shows only in pgAdmin

7.2k Views Asked by At

postgresql 9.4. I have a function

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');

I can see notice only from pgAmin, but nothing from ide or toad (and some other) db clients. How can I turn on output of "raise notice" or maybe there is other ways to get debug information?

UPDATE

I found a workaround: tail -F for a log file and set log_min_messages in postgresql.conf

1

There are 1 best solutions below

3
On

You need to adjust client_min_messages, like:

set client_min_messages = 'debug';

See http://www.postgresql.org/docs/9.1/static/runtime-config-logging.html#GUC-CLIENT-MIN-MESSAGES for more.

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=#