0

Say I run a function: select somefunction() and I wanna know what statement it is performing at the moment

select * from t does not help because it shows the 'select somefunction()' line and not the exact statement.

Is there a way to see what's up?

Thanks, h

1
  • SELECT * FROM t ? Eh? Do you mean select * from pg_stat_activity ? Commented Sep 10, 2012 at 7:12

2 Answers 2

1

You may want to use the PL/PgSQL debugger - which should be preinstalled in most PostgreSQL installs and is used via PgAdmin-III after activating it in postgresql.conf.

Alternately, consider adding RAISE NOTICE statements in your code at significant points you wish to know about.

There is no facility that I know of to get a "stack trace" of an active SQL statement including the (possibly nested) function calls. It'd be quite nice, but AFAIK nobody's implemented such a feature.

Sign up to request clarification or add additional context in comments.

Comments

0

This can help you.

CREATE FUNCTION somefunction() returns table(query text) as $$ select current_query::text from pg_stat_activity where current_query not like '% somefunction();' $$ language sql;

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.