1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-18 17:42:25 +03:00

Fix bad interaction between NOTIFY processing and V3 extended query

protocol, per report from Igor Shevchenko.  NOTIFY thought it could
do its thing if transaction blockState is TBLOCK_DEFAULT, but in
reality it had better check the low-level transaction state is
TRANS_DEFAULT as well.  Formerly it was not possible to wait for the
client in a state where the first is true and the second is not ...
but now we can have such a state.  Minor cleanup in StartTransaction()
as well.
This commit is contained in:
Tom Lane
2003-10-16 16:50:41 +00:00
parent 839cea8814
commit 90b2202975
4 changed files with 37 additions and 24 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.155 2003/09/28 23:26:20 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.156 2003/10/16 16:50:41 tgl Exp $
*
* NOTES
* Transaction aborts can now occur two ways:
@ -202,7 +202,7 @@ static TransactionStateData CurrentTransactionStateData = {
* perspective */
};
TransactionState CurrentTransactionState = &CurrentTransactionStateData;
static TransactionState CurrentTransactionState = &CurrentTransactionStateData;
/*
* User-tweakable parameters
@ -826,20 +826,11 @@ StartTransaction(void)
{
TransactionState s = CurrentTransactionState;
FreeXactSnapshot();
XactIsoLevel = DefaultXactIsoLevel;
XactReadOnly = DefaultXactReadOnly;
/*
* Check the current transaction state. If the transaction system is
* switched off, or if we're already in a transaction, do nothing.
* We're already in a transaction when the monitor sends a null
* command to the backend to flush the comm channel. This is a hacky
* fix to a communications problem, and we keep having to deal with it
* here. We should fix the comm channel code. mao 080891
* check the current transaction state
*/
if (s->state == TRANS_INPROGRESS)
return;
if (s->state != TRANS_DEFAULT)
elog(WARNING, "StartTransaction and not in default state");
/*
* set the current transaction state information appropriately during
@ -847,6 +838,13 @@ StartTransaction(void)
*/
s->state = TRANS_START;
/*
* Make sure we've freed any old snapshot, and reset xact state variables
*/
FreeXactSnapshot();
XactIsoLevel = DefaultXactIsoLevel;
XactReadOnly = DefaultXactReadOnly;
/*
* generate a new transaction id
*/
@ -1725,6 +1723,24 @@ IsTransactionBlock(void)
return true;
}
/*
* IsTransactionOrTransactionBlock --- are we within either a transaction
* or a transaction block? (The backend is only really "idle" when this
* returns false.)
*
* This should match up with IsTransactionBlock and IsTransactionState.
*/
bool
IsTransactionOrTransactionBlock(void)
{
TransactionState s = CurrentTransactionState;
if (s->blockState == TBLOCK_DEFAULT && s->state == TRANS_DEFAULT)
return false;
return true;
}
/*
* TransactionBlockStatusCode - return status code to send in ReadyForQuery
*/