When sitting inside an extension, and given an arbitrary TransactionId, how can you determine that it aborted/crashed *and* that no other active transaction thinks it is still running?
I've tried to answer this question myself (against the 9.3 sources), and it seems like it's just:
{
TransactionId oldestXmin = GetOldestXmin (false, false);
TransactionId xid = 42;
if (TransactionIdPrecedes(xid, oldestXmin) &&
!TransactionIdDidCommit(xid) &&
!TransactionIdIsInProgress(xid)) /* not even sure this is necessary? */
{
/* xid is aborted/crashed and no active transaction cares */
}
}
Can anyone confirm or deny that this is correct? I feel like it is correct, but I'm no expert.
Thanks so much for your time!
eric