mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	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
60b2444cc3, 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.
			
			
This commit is contained in:
		@@ -3861,7 +3861,24 @@ AbortOutOfAnyTransaction(void)
 | 
			
		||||
		switch (s->blockState)
 | 
			
		||||
		{
 | 
			
		||||
			case TBLOCK_DEFAULT:
 | 
			
		||||
				/* Not in a transaction, do nothing */
 | 
			
		||||
				if (s->state == TRANS_DEFAULT)
 | 
			
		||||
				{
 | 
			
		||||
					/* Not in a transaction, do nothing */
 | 
			
		||||
				}
 | 
			
		||||
				else
 | 
			
		||||
				{
 | 
			
		||||
					/*
 | 
			
		||||
					 * We can get here after an error during transaction start
 | 
			
		||||
					 * (state will be TRANS_START).  Need to clean up the
 | 
			
		||||
					 * incompletely started transaction.  First, adjust the
 | 
			
		||||
					 * low-level state to suppress warning message from
 | 
			
		||||
					 * AbortTransaction.
 | 
			
		||||
					 */
 | 
			
		||||
					if (s->state == TRANS_START)
 | 
			
		||||
						s->state = TRANS_INPROGRESS;
 | 
			
		||||
					AbortTransaction();
 | 
			
		||||
					CleanupTransaction();
 | 
			
		||||
				}
 | 
			
		||||
				break;
 | 
			
		||||
			case TBLOCK_STARTED:
 | 
			
		||||
			case TBLOCK_BEGIN:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user