mirror of
				https://github.com/postgres/postgres.git
				synced 2025-11-03 09:13:20 +03:00 
			
		
		
		
	Make GetSlotInvalidationCause() return RS_INVAL_NONE on unexpected input
943f7ae1c8 has changed GetSlotInvalidationCause() so as it would
return the last element of SlotInvalidationCauses[] when an incorrect
conflict reason name is given by a caller, but this should return
RS_INVAL_NONE in such cases, even if such a state should never be
reached in practice.
Per gripe from Peter Smith.
Reviewed-by: Bharath Rupireddy
Discussion: https://postgr.es/m/CAHut+PtsrSWxczpGkSaSVtJo+BXrvJ3Hwp5gES14bbL-G+HL7A@mail.gmail.com
			
			
This commit is contained in:
		@@ -2327,6 +2327,7 @@ ReplicationSlotInvalidationCause
 | 
				
			|||||||
GetSlotInvalidationCause(const char *conflict_reason)
 | 
					GetSlotInvalidationCause(const char *conflict_reason)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	ReplicationSlotInvalidationCause cause;
 | 
						ReplicationSlotInvalidationCause cause;
 | 
				
			||||||
 | 
						ReplicationSlotInvalidationCause result = RS_INVAL_NONE;
 | 
				
			||||||
	bool		found PG_USED_FOR_ASSERTS_ONLY = false;
 | 
						bool		found PG_USED_FOR_ASSERTS_ONLY = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Assert(conflict_reason);
 | 
						Assert(conflict_reason);
 | 
				
			||||||
@@ -2336,10 +2337,11 @@ GetSlotInvalidationCause(const char *conflict_reason)
 | 
				
			|||||||
		if (strcmp(SlotInvalidationCauses[cause], conflict_reason) == 0)
 | 
							if (strcmp(SlotInvalidationCauses[cause], conflict_reason) == 0)
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
			found = true;
 | 
								found = true;
 | 
				
			||||||
 | 
								result = cause;
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	Assert(found);
 | 
						Assert(found);
 | 
				
			||||||
	return cause;
 | 
						return result;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user