0

I'm using PgAdmin to create multiple pgsql functions. I'm beginner on this environment. I'm using 'raise notice' to help me for debugging phase.

I have two functions with 'raise notice' statement. The first function calls the second function.

I can show the 'raise notice' statement for the first function. I can't show the 'raise notice' statement for the second function. In place, the console show blank lines for each 'raise notice' that should be shown.

Function 1 - Example :

raise notice 'Function 1 executing';    -- This raise notice works
PERFORM public.function_2();

Function 2 - Example :

raise notice 'Function 2 is now running';   -- This raise notice doesn't work

Is it possible to do what I want?

2 Answers 2

0

Yes it is possible. I have tested the following with PG 12.2 and with psql CLI:

show client_min_messages;
client_min_messages 
---------------------
notice
(1 row) 
create or replace function f2 () returns text
as
$$
declare
begin
 raise notice 'Function 2 is now running';
 return 'f2: OK';
end;
$$
language plpgsql;
CREATE FUNCTION
create or replace function f1 () returns text
as
$$
declare
begin
 raise notice 'Function 1 executing';
 perform f2();
 return 'f1: OK';
end;
$$
language plpgsql;
CREATE FUNCTION
select f1();
psql:t2f.sql:27: NOTICE:  Function 1 executing
psql:t2f.sql:27: NOTICE:  Function 2 is now running
   f1   
--------
 f1: OK
(1 row)
1
  • Make sure client_min_messages is correctly set and not modified by your code. Are you writing something else to standard output ? Is there any message in database log ?
    – pifor
    Mar 24, 2020 at 11:08
0

Thank you for responding,

I never needed to change any parameter of PostGre server or PgAdmin. So, I don't know them well. I'm not sure about my PgAdmin version, the 'About' form say 1.20 (?!)

My client_min_messages is like you and my code doesn' modify it.

The result in the messages panel is a little different than you, like that :

NOTICE: Function 1 executing

[Blank line]

Total duration of request execution :23 ms. 1 line recovered.

There are [Blank line] as many times I call the function 2.

8
  • can you try to test it using psql CLI interface ? It it works it means it's a pgAdmin issue.
    – pifor
    Mar 24, 2020 at 12:33
  • Sorry for my lack of knowledge, what is 'psql CLI interface'. I'm only working in PgAdmin Desktop to create and launch my functions. Is it PSQL Console ?
    – Stoooff
    Mar 24, 2020 at 12:37
  • PG Version is 9.4
    – Stoooff
    Mar 24, 2020 at 12:43
  • yes it's PSQL Console (psql.exe on Windows - psql executable on Linux). I recommend also to upgrade pgAdmin to a more recent version.
    – pifor
    Mar 24, 2020 at 12:45
  • Ok, I go for installing last version and try it. The psql console generate an error on the PERFORM statement (invalid byte sequence for encoding "UTF8": 0xab), if i remove the PERFORM, there is no error.
    – Stoooff
    Mar 24, 2020 at 12:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.