Attached is a first revision of a patch that adds a column to
pg_stat_activity containing the time at which the backend's current
transaction began, or NULL if the backend is not inside a transaction.
This is useful for finding long-running transactions, and AFAIK this
information is not otherwise easily available from outside the backend's
session.
Naturally, this is for 8.3.
-Neil