Now that Heikki's two-phase-commit patch is in, we have a bit of a
problem in the pg_locks view: prepared transactions can hold locks,
but you can't tell which prepared transaction is holding which lock.
They all show with "pid 0". (This should probably come out as a NULL
instead of 0, but I didn't change it yet.)
I think the minimum thing we ought to do about this is add an XID
column to pg_locks to show the transaction ID holding each lock.
Then you could join that to pg_prepared_xacts to see what's what.
I was also wondering about adding a current-XID column to
pg_stat_activity, and encouraging people to join pg_locks and
pg_stat_activity on XID instead of PID.
Ultimately we should maybe even remove PID from pg_locks, but probably
for backwards compatibility it'd have to be deprecated for a release
or two first.
Thoughts?
regards, tom lane