Subject: show fct_name of the function/procedure

From: ft <[email-masked]>
Date: Sat, 27 Apr 2024 21:53:07 +0200

Hello, 

I need (a very simple construct) to show the fct_name/proc_name 
for the function/procedure.

Example:
create procedure/function bet_process() as 
$$
declare
 pid      int  := pg_backend_pid() ; --  it works fine
 fct_name text := pg_fct_name()    ; --  I need it
begin
 -- do s.th like 
 -- call log(pid, fct_name, 'my message');
end;
$$ language plpgsql;

Franz

---

From: "David G. Johnston" <[email-masked]>
Date: Sat, 27 Apr 2024 13:01:30 -0700

>  fct_name text := pg_fct_name()    ; --  I need it

https://www.postgresql.org/docs/current/plpgsql-statements.html#PLPGSQL-STATEMENTS-DIAGNOSTICS

PG_ROUTINE_OID

I think casting that to “regproc” will get you what you need.  Otherwise
there should be functions or a query to perform the needed lookup.

https://www.postgresql.org/docs/current/datatype-oid.html

David J.