Suppose
CREATE OR REPLACE FUNCTION report.dummy_func1() RETURNS integer AS $$
DECLARE
BEGIN
PERFORM pg_sleep(10);
RETURN 1;
END;
$$ LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION report.dummy_func() RETURNS integer AS $$
DECLARE
BEGIN
PERFORM pg_sleep(5);
PERFORM report.dummy_func1();
RETURN 1;
END;
$$ LANGUAGE plpgsql;
Select report.dummy_func();
With the above setup, is there a way to identify which function is currently being executed?
One way to identify is using pg_stat_activity, but it doesn't show which function is being executed.
Is there a reliable way to find whether a function is executing or not in postgresql.
My original requirement is to invoke a function, only if it is not already running. Is there a better way to achieve this in postgresql?