waiting for 8.4 - current_query()
unfrotunatelly i can’t point you to message in archives, as there is some problem with them, and i dont see posts newer than “Fri Apr 04 12:00:08 2008″.
this patch was written by tomas doran, and commited by bruce momjian:
Log Message:
-----------
Implement current_query(), that shows the currently executing query.
At the same time remove dblink/dblink_current_query() as it is no longer
necessary
*BACKWARD COMPATIBILITY ISSUE* for dblink
to be honest, at first i didn’t see why it was commited. then i recomplied postgresql with this new functionality and tested it.
i still dont quite get why it was added. as i see it, it’s a wrapper around:
select current_query from pg_stat_activity where procpid = pg_backend_pid();
it’s nice to have it wrapped in single function, but to be honest - i dont really see the point.
on the other hand - one important benefit is that current_query() works even if i have track_activities set to off. which is nice.
manual say, that this function returns “text of the currently executing query (might contain more than one statement)”.
i dont see (at the moment) when there might be more than one currently executing query. i guess it has to be something with spi, but in my (short) tests i haven’t found a case when i would have 2 queries running.
maybe you can show me such cases?