"Jeroen T. Vermeulen" <jtv@xs4all.nl> writes:
> Some of you may remember that we discussed libpqxx's higher-level
> support for transactionality.
> [complicated scheme]
Another way you can look to see if a transaction has completed is to see
if there is still an ExclusiveLock record for it in pg_locks. For this
you need to know the transaction's internal XID, but you can get that
from the XMAX of the log record it deleted. In other words:
insert log record;begin;delete log record;<<payload work>>commit;
On reconnect:
log record not present: it committedelse, read XMAX from log recordzero -> failed before the delete :-(not zero -> look
formatch in pg_locksfound -> transaction still in progress, waitnot found -> it aborted
This is all pretty messy though. Seems like it would be a whole lot
easier if the backend exposed ways to (a) obtain your current
transaction number and (b) inquire directly about the commit status of
a transaction. However, with the present transaction infrastructure
(b) would only work for a limited time window after the original
transaction (until the corresponding clog space got recycled). So that
might or might not be good enough for your purposes.
regards, tom lane