Skip to content

Commit 2755abf

Browse files
committed
Teach AbortOutOfAnyTransaction to clean up partially-started transactions.
AbortOutOfAnyTransaction failed to do anything if the state it saw on entry corresponded to failing partway through StartTransaction. I fixed AbortCurrentTransaction to cope with that case way back in commit 60b2444, but evidently overlooked that AbortOutOfAnyTransaction should do likewise. Back-patch to all supported branches. It's not clear that this omission has any more-than-cosmetic consequences, but it's also not clear that it doesn't, so back-patching seems the least risky choice.
1 parent c89bdf7 commit 2755abf

File tree

1 file changed

+18
-1
lines changed
  • src/backend/access/transam

1 file changed

+18
-1
lines changed

src/backend/access/transam/xact.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3861,7 +3861,24 @@ AbortOutOfAnyTransaction(void)
38613861
switch (s->blockState)
38623862
{
38633863
case TBLOCK_DEFAULT:
3864-
/* Not in a transaction, do nothing */
3864+
if (s->state == TRANS_DEFAULT)
3865+
{
3866+
/* Not in a transaction, do nothing */
3867+
}
3868+
else
3869+
{
3870+
/*
3871+
* We can get here after an error during transaction start
3872+
* (state will be TRANS_START). Need to clean up the
3873+
* incompletely started transaction. First, adjust the
3874+
* low-level state to suppress warning message from
3875+
* AbortTransaction.
3876+
*/
3877+
if (s->state == TRANS_START)
3878+
s->state = TRANS_INPROGRESS;
3879+
AbortTransaction();
3880+
CleanupTransaction();
3881+
}
38653882
break;
38663883
case TBLOCK_STARTED:
38673884
case TBLOCK_BEGIN:

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