Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit efa70c1

Browse files
committed
Make GetSlotInvalidationCause() return RS_INVAL_NONE on unexpected input
943f7ae 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
1 parent 93db6cb commit efa70c1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/backend/replication/slot.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2327,6 +2327,7 @@ ReplicationSlotInvalidationCause
23272327
GetSlotInvalidationCause(const char *conflict_reason)
23282328
{
23292329
ReplicationSlotInvalidationCause cause;
2330+
ReplicationSlotInvalidationCause result = RS_INVAL_NONE;
23302331
bool found PG_USED_FOR_ASSERTS_ONLY = false;
23312332

23322333
Assert(conflict_reason);
@@ -2336,10 +2337,11 @@ GetSlotInvalidationCause(const char *conflict_reason)
23362337
if (strcmp(SlotInvalidationCauses[cause], conflict_reason) == 0)
23372338
{
23382339
found = true;
2340+
result = cause;
23392341
break;
23402342
}
23412343
}
23422344

23432345
Assert(found);
2344-
return cause;
2346+
return result;
23452347
}

0 commit comments

Comments
 (0)