jtv@xs4all.nl writes:
> Tom, I believe you said at the time that I should check pg_stat_activity.
> My current code polls it for the old backend pid. But if that is neither
> 100% reliable nor unconditionally available, wouldn't it be better if I
> just queried pg_locks for the transaction's ID? Would that work for all
> backend versions I can expect to see?
pg_locks certainly seems like a better solution. Perhaps it didn't
exist when you went with pg_stat_activity? Can't recall offhand.
Note that you still want to look for your old backend's PID; it seems
impractically expensive to keep track of the current transaction's XID.
(At a minimum that would cost another query per xact...)
regards, tom lane