Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use log or debug within stored procedure of PgSql?

I want to debug or use log for a PgSql stored Procedure. Can any one help me ?

like image 958
vicky Avatar asked Sep 15 '25 09:09

vicky


1 Answers

The usual method is to use RAISE NOTICE inside of a PLPGSQL function:

create function test(some_string text) returns void as $$
  BEGIN
    RAISE NOTICE 'Some string: %', some_string;
  END
$$
LANGUAGE PLPGSQL;

# select test('!');
psql: NOTICE:  Some string: !
 test
------

(1 row)

Whether this message actually shows up in the logs and for the client depends on the settings of log_min_messages and client_min_messages, respectively.

like image 149
Jeremy Avatar answered Sep 18 '25 10:09

Jeremy