1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-07 00:36:50 +03:00

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.
This commit is contained in:
Tom Lane
2007-06-07 21:45:59 +00:00
parent 24ee8af573
commit 6d6d14b6d5
3 changed files with 23 additions and 39 deletions

View File

@ -42,7 +42,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.185 2007/05/04 02:01:02 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/error/elog.c,v 1.186 2007/06/07 21:45:59 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -1593,12 +1593,7 @@ log_line_prefix(StringInfo buf)
break;
case 'x':
if (MyProcPort)
{
if (IsTransactionState())
appendStringInfo(buf, "%u", GetTopTransactionId());
else
appendStringInfo(buf, "%u", InvalidTransactionId);
}
appendStringInfo(buf, "%u", GetTopTransactionId());
break;
case '%':
appendStringInfoChar(buf, '%');