Fix AbortOutOfAnyTransaction logic to avoid notice about
'AbortTransaction and not in in-progress state' when client disconnects just after an error. Notice seems pretty harmless, so I'm not going to worry about back-patching this into 7.0.* ...
This commit is contained in:
parent
f9b2298bb3
commit
fa9357d0b7
|
@ -8,7 +8,7 @@
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.76 2000/10/24 09:56:08 vadim Exp $
|
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.77 2000/10/24 20:06:39 tgl Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* Transaction aborts can now occur two ways:
|
* Transaction aborts can now occur two ways:
|
||||||
|
@ -344,7 +344,7 @@ IsTransactionState(void)
|
||||||
* --------------------------------
|
* --------------------------------
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
IsAbortedTransactionBlockState()
|
IsAbortedTransactionBlockState(void)
|
||||||
{
|
{
|
||||||
TransactionState s = CurrentTransactionState;
|
TransactionState s = CurrentTransactionState;
|
||||||
|
|
||||||
|
@ -395,7 +395,7 @@ OverrideTransactionSystem(bool flag)
|
||||||
* --------------------------------
|
* --------------------------------
|
||||||
*/
|
*/
|
||||||
TransactionId
|
TransactionId
|
||||||
GetCurrentTransactionId()
|
GetCurrentTransactionId(void)
|
||||||
{
|
{
|
||||||
TransactionState s = CurrentTransactionState;
|
TransactionState s = CurrentTransactionState;
|
||||||
|
|
||||||
|
@ -420,7 +420,7 @@ GetCurrentTransactionId()
|
||||||
* --------------------------------
|
* --------------------------------
|
||||||
*/
|
*/
|
||||||
CommandId
|
CommandId
|
||||||
GetCurrentCommandId()
|
GetCurrentCommandId(void)
|
||||||
{
|
{
|
||||||
TransactionState s = CurrentTransactionState;
|
TransactionState s = CurrentTransactionState;
|
||||||
|
|
||||||
|
@ -436,7 +436,7 @@ GetCurrentCommandId()
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandId
|
CommandId
|
||||||
GetScanCommandId()
|
GetScanCommandId(void)
|
||||||
{
|
{
|
||||||
TransactionState s = CurrentTransactionState;
|
TransactionState s = CurrentTransactionState;
|
||||||
|
|
||||||
|
@ -457,7 +457,7 @@ GetScanCommandId()
|
||||||
* --------------------------------
|
* --------------------------------
|
||||||
*/
|
*/
|
||||||
AbsoluteTime
|
AbsoluteTime
|
||||||
GetCurrentTransactionStartTime()
|
GetCurrentTransactionStartTime(void)
|
||||||
{
|
{
|
||||||
TransactionState s = CurrentTransactionState;
|
TransactionState s = CurrentTransactionState;
|
||||||
|
|
||||||
|
@ -523,7 +523,7 @@ CommandIdGEScanCommandId(CommandId cid)
|
||||||
*/
|
*/
|
||||||
#ifdef NOT_USED
|
#ifdef NOT_USED
|
||||||
void
|
void
|
||||||
ClearCommandIdCounterOverflowFlag()
|
ClearCommandIdCounterOverflowFlag(void)
|
||||||
{
|
{
|
||||||
CommandIdCounterOverflowFlag = false;
|
CommandIdCounterOverflowFlag = false;
|
||||||
}
|
}
|
||||||
|
@ -535,7 +535,7 @@ ClearCommandIdCounterOverflowFlag()
|
||||||
* --------------------------------
|
* --------------------------------
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
CommandCounterIncrement()
|
CommandCounterIncrement(void)
|
||||||
{
|
{
|
||||||
CurrentTransactionStateData.commandId += 1;
|
CurrentTransactionStateData.commandId += 1;
|
||||||
if (CurrentTransactionStateData.commandId == FirstCommandId)
|
if (CurrentTransactionStateData.commandId == FirstCommandId)
|
||||||
|
@ -568,7 +568,7 @@ SetScanCommandId(CommandId savedId)
|
||||||
* ----------------------------------------------------------------
|
* ----------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
InitializeTransactionSystem()
|
InitializeTransactionSystem(void)
|
||||||
{
|
{
|
||||||
InitializeTransactionLog();
|
InitializeTransactionLog();
|
||||||
}
|
}
|
||||||
|
@ -583,7 +583,7 @@ InitializeTransactionSystem()
|
||||||
* --------------------------------
|
* --------------------------------
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
AtStart_Cache()
|
AtStart_Cache(void)
|
||||||
{
|
{
|
||||||
DiscardInvalid();
|
DiscardInvalid();
|
||||||
}
|
}
|
||||||
|
@ -593,7 +593,7 @@ AtStart_Cache()
|
||||||
* --------------------------------
|
* --------------------------------
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
AtStart_Locks()
|
AtStart_Locks(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -609,7 +609,7 @@ AtStart_Locks()
|
||||||
* --------------------------------
|
* --------------------------------
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
AtStart_Memory()
|
AtStart_Memory(void)
|
||||||
{
|
{
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* We shouldn't have any transaction contexts already.
|
* We shouldn't have any transaction contexts already.
|
||||||
|
@ -659,7 +659,7 @@ AtStart_Memory()
|
||||||
* --------------------------------
|
* --------------------------------
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
RecordTransactionCommit()
|
RecordTransactionCommit(void)
|
||||||
{
|
{
|
||||||
TransactionId xid;
|
TransactionId xid;
|
||||||
int leak;
|
int leak;
|
||||||
|
@ -740,7 +740,7 @@ RecordTransactionCommit()
|
||||||
* --------------------------------
|
* --------------------------------
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
AtCommit_Cache()
|
AtCommit_Cache(void)
|
||||||
{
|
{
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* Make catalog changes visible to all backend.
|
* Make catalog changes visible to all backend.
|
||||||
|
@ -754,7 +754,7 @@ AtCommit_Cache()
|
||||||
* --------------------------------
|
* --------------------------------
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
AtCommit_LocalCache()
|
AtCommit_LocalCache(void)
|
||||||
{
|
{
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* Make catalog changes visible to me for the next command.
|
* Make catalog changes visible to me for the next command.
|
||||||
|
@ -768,7 +768,7 @@ AtCommit_LocalCache()
|
||||||
* --------------------------------
|
* --------------------------------
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
AtCommit_Locks()
|
AtCommit_Locks(void)
|
||||||
{
|
{
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* XXX What if ProcReleaseLocks fails? (race condition?)
|
* XXX What if ProcReleaseLocks fails? (race condition?)
|
||||||
|
@ -784,7 +784,7 @@ AtCommit_Locks()
|
||||||
* --------------------------------
|
* --------------------------------
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
AtCommit_Memory()
|
AtCommit_Memory(void)
|
||||||
{
|
{
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* Now that we're "out" of a transaction, have the
|
* Now that we're "out" of a transaction, have the
|
||||||
|
@ -814,7 +814,7 @@ AtCommit_Memory()
|
||||||
* --------------------------------
|
* --------------------------------
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
RecordTransactionAbort()
|
RecordTransactionAbort(void)
|
||||||
{
|
{
|
||||||
TransactionId xid;
|
TransactionId xid;
|
||||||
|
|
||||||
|
@ -855,7 +855,7 @@ RecordTransactionAbort()
|
||||||
* --------------------------------
|
* --------------------------------
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
AtAbort_Cache()
|
AtAbort_Cache(void)
|
||||||
{
|
{
|
||||||
RelationCacheAbort();
|
RelationCacheAbort();
|
||||||
SystemCacheAbort();
|
SystemCacheAbort();
|
||||||
|
@ -867,7 +867,7 @@ AtAbort_Cache()
|
||||||
* --------------------------------
|
* --------------------------------
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
AtAbort_Locks()
|
AtAbort_Locks(void)
|
||||||
{
|
{
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* XXX What if ProcReleaseLocks() fails? (race condition?)
|
* XXX What if ProcReleaseLocks() fails? (race condition?)
|
||||||
|
@ -884,7 +884,7 @@ AtAbort_Locks()
|
||||||
* --------------------------------
|
* --------------------------------
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
AtAbort_Memory()
|
AtAbort_Memory(void)
|
||||||
{
|
{
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* Make sure we are in a valid context (not a child of
|
* Make sure we are in a valid context (not a child of
|
||||||
|
@ -921,7 +921,7 @@ AtAbort_Memory()
|
||||||
* --------------------------------
|
* --------------------------------
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
AtCleanup_Memory()
|
AtCleanup_Memory(void)
|
||||||
{
|
{
|
||||||
/* ----------------
|
/* ----------------
|
||||||
* Now that we're "out" of a transaction, have the
|
* Now that we're "out" of a transaction, have the
|
||||||
|
@ -953,7 +953,7 @@ AtCleanup_Memory()
|
||||||
* --------------------------------
|
* --------------------------------
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
StartTransaction()
|
StartTransaction(void)
|
||||||
{
|
{
|
||||||
TransactionState s = CurrentTransactionState;
|
TransactionState s = CurrentTransactionState;
|
||||||
|
|
||||||
|
@ -1026,7 +1026,7 @@ StartTransaction()
|
||||||
* ---------------
|
* ---------------
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
CurrentXactInProgress()
|
CurrentXactInProgress(void)
|
||||||
{
|
{
|
||||||
return CurrentTransactionState->state == TRANS_INPROGRESS;
|
return CurrentTransactionState->state == TRANS_INPROGRESS;
|
||||||
}
|
}
|
||||||
|
@ -1038,7 +1038,7 @@ CurrentXactInProgress()
|
||||||
* --------------------------------
|
* --------------------------------
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
CommitTransaction()
|
CommitTransaction(void)
|
||||||
{
|
{
|
||||||
TransactionState s = CurrentTransactionState;
|
TransactionState s = CurrentTransactionState;
|
||||||
|
|
||||||
|
@ -1124,7 +1124,7 @@ CommitTransaction()
|
||||||
* --------------------------------
|
* --------------------------------
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
AbortTransaction()
|
AbortTransaction(void)
|
||||||
{
|
{
|
||||||
TransactionState s = CurrentTransactionState;
|
TransactionState s = CurrentTransactionState;
|
||||||
|
|
||||||
|
@ -1205,7 +1205,7 @@ AbortTransaction()
|
||||||
* --------------------------------
|
* --------------------------------
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
CleanupTransaction()
|
CleanupTransaction(void)
|
||||||
{
|
{
|
||||||
TransactionState s = CurrentTransactionState;
|
TransactionState s = CurrentTransactionState;
|
||||||
|
|
||||||
|
@ -1238,7 +1238,7 @@ CleanupTransaction()
|
||||||
* --------------------------------
|
* --------------------------------
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
StartTransactionCommand()
|
StartTransactionCommand(void)
|
||||||
{
|
{
|
||||||
TransactionState s = CurrentTransactionState;
|
TransactionState s = CurrentTransactionState;
|
||||||
|
|
||||||
|
@ -1326,7 +1326,7 @@ StartTransactionCommand()
|
||||||
* --------------------------------
|
* --------------------------------
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
CommitTransactionCommand()
|
CommitTransactionCommand(void)
|
||||||
{
|
{
|
||||||
TransactionState s = CurrentTransactionState;
|
TransactionState s = CurrentTransactionState;
|
||||||
|
|
||||||
|
@ -1407,7 +1407,7 @@ CommitTransactionCommand()
|
||||||
* --------------------------------
|
* --------------------------------
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
AbortCurrentTransaction()
|
AbortCurrentTransaction(void)
|
||||||
{
|
{
|
||||||
TransactionState s = CurrentTransactionState;
|
TransactionState s = CurrentTransactionState;
|
||||||
|
|
||||||
|
@ -1636,7 +1636,7 @@ AbortTransactionBlock(void)
|
||||||
* --------------------------------
|
* --------------------------------
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
UserAbortTransactionBlock()
|
UserAbortTransactionBlock(void)
|
||||||
{
|
{
|
||||||
TransactionState s = CurrentTransactionState;
|
TransactionState s = CurrentTransactionState;
|
||||||
|
|
||||||
|
@ -1696,17 +1696,30 @@ UserAbortTransactionBlock()
|
||||||
* --------------------------------
|
* --------------------------------
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
AbortOutOfAnyTransaction()
|
AbortOutOfAnyTransaction(void)
|
||||||
{
|
{
|
||||||
TransactionState s = CurrentTransactionState;
|
TransactionState s = CurrentTransactionState;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get out of any low-level transaction
|
* Get out of any low-level transaction
|
||||||
*/
|
*/
|
||||||
if (s->state != TRANS_DEFAULT)
|
switch (s->state)
|
||||||
{
|
{
|
||||||
|
case TRANS_START:
|
||||||
|
case TRANS_INPROGRESS:
|
||||||
|
case TRANS_COMMIT:
|
||||||
|
/* In a transaction, so clean up */
|
||||||
AbortTransaction();
|
AbortTransaction();
|
||||||
CleanupTransaction();
|
CleanupTransaction();
|
||||||
|
break;
|
||||||
|
case TRANS_ABORT:
|
||||||
|
/* AbortTransaction already done, still need Cleanup */
|
||||||
|
CleanupTransaction();
|
||||||
|
break;
|
||||||
|
case TRANS_DEFAULT:
|
||||||
|
case TRANS_DISABLED:
|
||||||
|
/* Not in a transaction, do nothing */
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1716,7 +1729,7 @@ AbortOutOfAnyTransaction()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
IsTransactionBlock()
|
IsTransactionBlock(void)
|
||||||
{
|
{
|
||||||
TransactionState s = CurrentTransactionState;
|
TransactionState s = CurrentTransactionState;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue