Skip to content

Commit fa9357d

Browse files
committed
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.* ...
1 parent f9b2298 commit fa9357d

File tree

1 file changed

+49
-36
lines changed
  • src/backend/access/transam

1 file changed

+49
-36
lines changed

src/backend/access/transam/xact.c

Lines changed: 49 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.76 2000/10/24 09:56:08 vadim Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.77 2000/10/24 20:06:39 tgl Exp $
1212
*
1313
* NOTES
1414
* Transaction aborts can now occur two ways:
@@ -344,7 +344,7 @@ IsTransactionState(void)
344344
* --------------------------------
345345
*/
346346
bool
347-
IsAbortedTransactionBlockState()
347+
IsAbortedTransactionBlockState(void)
348348
{
349349
TransactionState s = CurrentTransactionState;
350350

@@ -395,7 +395,7 @@ OverrideTransactionSystem(bool flag)
395395
* --------------------------------
396396
*/
397397
TransactionId
398-
GetCurrentTransactionId()
398+
GetCurrentTransactionId(void)
399399
{
400400
TransactionState s = CurrentTransactionState;
401401

@@ -420,7 +420,7 @@ GetCurrentTransactionId()
420420
* --------------------------------
421421
*/
422422
CommandId
423-
GetCurrentCommandId()
423+
GetCurrentCommandId(void)
424424
{
425425
TransactionState s = CurrentTransactionState;
426426

@@ -436,7 +436,7 @@ GetCurrentCommandId()
436436
}
437437

438438
CommandId
439-
GetScanCommandId()
439+
GetScanCommandId(void)
440440
{
441441
TransactionState s = CurrentTransactionState;
442442

@@ -457,7 +457,7 @@ GetScanCommandId()
457457
* --------------------------------
458458
*/
459459
AbsoluteTime
460-
GetCurrentTransactionStartTime()
460+
GetCurrentTransactionStartTime(void)
461461
{
462462
TransactionState s = CurrentTransactionState;
463463

@@ -523,7 +523,7 @@ CommandIdGEScanCommandId(CommandId cid)
523523
*/
524524
#ifdef NOT_USED
525525
void
526-
ClearCommandIdCounterOverflowFlag()
526+
ClearCommandIdCounterOverflowFlag(void)
527527
{
528528
CommandIdCounterOverflowFlag = false;
529529
}
@@ -535,7 +535,7 @@ ClearCommandIdCounterOverflowFlag()
535535
* --------------------------------
536536
*/
537537
void
538-
CommandCounterIncrement()
538+
CommandCounterIncrement(void)
539539
{
540540
CurrentTransactionStateData.commandId += 1;
541541
if (CurrentTransactionStateData.commandId == FirstCommandId)
@@ -568,7 +568,7 @@ SetScanCommandId(CommandId savedId)
568568
* ----------------------------------------------------------------
569569
*/
570570
void
571-
InitializeTransactionSystem()
571+
InitializeTransactionSystem(void)
572572
{
573573
InitializeTransactionLog();
574574
}
@@ -583,7 +583,7 @@ InitializeTransactionSystem()
583583
* --------------------------------
584584
*/
585585
static void
586-
AtStart_Cache()
586+
AtStart_Cache(void)
587587
{
588588
DiscardInvalid();
589589
}
@@ -593,7 +593,7 @@ AtStart_Cache()
593593
* --------------------------------
594594
*/
595595
static void
596-
AtStart_Locks()
596+
AtStart_Locks(void)
597597
{
598598

599599
/*
@@ -609,7 +609,7 @@ AtStart_Locks()
609609
* --------------------------------
610610
*/
611611
static void
612-
AtStart_Memory()
612+
AtStart_Memory(void)
613613
{
614614
/* ----------------
615615
* We shouldn't have any transaction contexts already.
@@ -659,7 +659,7 @@ AtStart_Memory()
659659
* --------------------------------
660660
*/
661661
static void
662-
RecordTransactionCommit()
662+
RecordTransactionCommit(void)
663663
{
664664
TransactionId xid;
665665
int leak;
@@ -740,7 +740,7 @@ RecordTransactionCommit()
740740
* --------------------------------
741741
*/
742742
static void
743-
AtCommit_Cache()
743+
AtCommit_Cache(void)
744744
{
745745
/* ----------------
746746
* Make catalog changes visible to all backend.
@@ -754,7 +754,7 @@ AtCommit_Cache()
754754
* --------------------------------
755755
*/
756756
static void
757-
AtCommit_LocalCache()
757+
AtCommit_LocalCache(void)
758758
{
759759
/* ----------------
760760
* Make catalog changes visible to me for the next command.
@@ -768,7 +768,7 @@ AtCommit_LocalCache()
768768
* --------------------------------
769769
*/
770770
static void
771-
AtCommit_Locks()
771+
AtCommit_Locks(void)
772772
{
773773
/* ----------------
774774
* XXX What if ProcReleaseLocks fails? (race condition?)
@@ -784,7 +784,7 @@ AtCommit_Locks()
784784
* --------------------------------
785785
*/
786786
static void
787-
AtCommit_Memory()
787+
AtCommit_Memory(void)
788788
{
789789
/* ----------------
790790
* Now that we're "out" of a transaction, have the
@@ -814,7 +814,7 @@ AtCommit_Memory()
814814
* --------------------------------
815815
*/
816816
static void
817-
RecordTransactionAbort()
817+
RecordTransactionAbort(void)
818818
{
819819
TransactionId xid;
820820

@@ -855,7 +855,7 @@ RecordTransactionAbort()
855855
* --------------------------------
856856
*/
857857
static void
858-
AtAbort_Cache()
858+
AtAbort_Cache(void)
859859
{
860860
RelationCacheAbort();
861861
SystemCacheAbort();
@@ -867,7 +867,7 @@ AtAbort_Cache()
867867
* --------------------------------
868868
*/
869869
static void
870-
AtAbort_Locks()
870+
AtAbort_Locks(void)
871871
{
872872
/* ----------------
873873
* XXX What if ProcReleaseLocks() fails? (race condition?)
@@ -884,7 +884,7 @@ AtAbort_Locks()
884884
* --------------------------------
885885
*/
886886
static void
887-
AtAbort_Memory()
887+
AtAbort_Memory(void)
888888
{
889889
/* ----------------
890890
* Make sure we are in a valid context (not a child of
@@ -921,7 +921,7 @@ AtAbort_Memory()
921921
* --------------------------------
922922
*/
923923
static void
924-
AtCleanup_Memory()
924+
AtCleanup_Memory(void)
925925
{
926926
/* ----------------
927927
* Now that we're "out" of a transaction, have the
@@ -953,7 +953,7 @@ AtCleanup_Memory()
953953
* --------------------------------
954954
*/
955955
static void
956-
StartTransaction()
956+
StartTransaction(void)
957957
{
958958
TransactionState s = CurrentTransactionState;
959959

@@ -1026,7 +1026,7 @@ StartTransaction()
10261026
* ---------------
10271027
*/
10281028
bool
1029-
CurrentXactInProgress()
1029+
CurrentXactInProgress(void)
10301030
{
10311031
return CurrentTransactionState->state == TRANS_INPROGRESS;
10321032
}
@@ -1038,7 +1038,7 @@ CurrentXactInProgress()
10381038
* --------------------------------
10391039
*/
10401040
static void
1041-
CommitTransaction()
1041+
CommitTransaction(void)
10421042
{
10431043
TransactionState s = CurrentTransactionState;
10441044

@@ -1124,7 +1124,7 @@ CommitTransaction()
11241124
* --------------------------------
11251125
*/
11261126
static void
1127-
AbortTransaction()
1127+
AbortTransaction(void)
11281128
{
11291129
TransactionState s = CurrentTransactionState;
11301130

@@ -1205,7 +1205,7 @@ AbortTransaction()
12051205
* --------------------------------
12061206
*/
12071207
static void
1208-
CleanupTransaction()
1208+
CleanupTransaction(void)
12091209
{
12101210
TransactionState s = CurrentTransactionState;
12111211

@@ -1238,7 +1238,7 @@ CleanupTransaction()
12381238
* --------------------------------
12391239
*/
12401240
void
1241-
StartTransactionCommand()
1241+
StartTransactionCommand(void)
12421242
{
12431243
TransactionState s = CurrentTransactionState;
12441244

@@ -1326,7 +1326,7 @@ StartTransactionCommand()
13261326
* --------------------------------
13271327
*/
13281328
void
1329-
CommitTransactionCommand()
1329+
CommitTransactionCommand(void)
13301330
{
13311331
TransactionState s = CurrentTransactionState;
13321332

@@ -1407,7 +1407,7 @@ CommitTransactionCommand()
14071407
* --------------------------------
14081408
*/
14091409
void
1410-
AbortCurrentTransaction()
1410+
AbortCurrentTransaction(void)
14111411
{
14121412
TransactionState s = CurrentTransactionState;
14131413

@@ -1636,7 +1636,7 @@ AbortTransactionBlock(void)
16361636
* --------------------------------
16371637
*/
16381638
void
1639-
UserAbortTransactionBlock()
1639+
UserAbortTransactionBlock(void)
16401640
{
16411641
TransactionState s = CurrentTransactionState;
16421642

@@ -1696,17 +1696,30 @@ UserAbortTransactionBlock()
16961696
* --------------------------------
16971697
*/
16981698
void
1699-
AbortOutOfAnyTransaction()
1699+
AbortOutOfAnyTransaction(void)
17001700
{
17011701
TransactionState s = CurrentTransactionState;
17021702

17031703
/*
17041704
* Get out of any low-level transaction
17051705
*/
1706-
if (s->state != TRANS_DEFAULT)
1706+
switch (s->state)
17071707
{
1708-
AbortTransaction();
1709-
CleanupTransaction();
1708+
case TRANS_START:
1709+
case TRANS_INPROGRESS:
1710+
case TRANS_COMMIT:
1711+
/* In a transaction, so clean up */
1712+
AbortTransaction();
1713+
CleanupTransaction();
1714+
break;
1715+
case TRANS_ABORT:
1716+
/* AbortTransaction already done, still need Cleanup */
1717+
CleanupTransaction();
1718+
break;
1719+
case TRANS_DEFAULT:
1720+
case TRANS_DISABLED:
1721+
/* Not in a transaction, do nothing */
1722+
break;
17101723
}
17111724

17121725
/*
@@ -1716,7 +1729,7 @@ AbortOutOfAnyTransaction()
17161729
}
17171730

17181731
bool
1719-
IsTransactionBlock()
1732+
IsTransactionBlock(void)
17201733
{
17211734
TransactionState s = CurrentTransactionState;
17221735

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy