Redefine IsTransactionState() to only return true for TRANS_INPROGRESS state,
Tom Lane <tgl@sss.pgh.pa.us>
Redefine IsTransactionState() to only return true for TRANS_INPROGRESS state, which is the only state in which it's safe to initiate database queries. It turns out that all but two of the callers thought that's what it meant; and the other two were using it as a proxy for "will GetTopTransactionId() return a nonzero XID"? Since it was in fact an unreliable guide to that, make those two just invoke GetTopTransactionId() always, then deal with a zero result if they get one.
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/access/transam/xact.c | modified | +18 −28 |
| src/backend/storage/ipc/procarray.c | modified | +3 −4 |
| src/backend/utils/error/elog.c | modified | +2 −7 |