mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
Add lookup table for replication slot conflict reasons
This commit switches the handling of the conflict cause strings for
replication slots to use a table rather than being explicitly listed,
using a C99-designated initializer syntax for the array elements. This
makes the whole more readable while easing future maintenance with less
areas to update when adding a new conflict reason.
This is similar to 74a7306310, but the scale of the change is smaller
as there are less conflict causes than LWLock builtin tranche names.
Author: Bharath Rupireddy
Reviewed-by: Jelte Fennema-Nio
Discussion: https://postgr.es/m/CALj2ACUxSLA91QGFrJsWNKs58KXb1C03mbuwKmzqqmoAKLwJaw@mail.gmail.com
This commit is contained in:
@@ -413,24 +413,12 @@ pg_get_replication_slots(PG_FUNCTION_ARGS)
|
||||
nulls[i++] = true;
|
||||
else
|
||||
{
|
||||
switch (slot_contents.data.invalidated)
|
||||
{
|
||||
case RS_INVAL_NONE:
|
||||
nulls[i++] = true;
|
||||
break;
|
||||
ReplicationSlotInvalidationCause cause = slot_contents.data.invalidated;
|
||||
|
||||
case RS_INVAL_WAL_REMOVED:
|
||||
values[i++] = CStringGetTextDatum(SLOT_INVAL_WAL_REMOVED_TEXT);
|
||||
break;
|
||||
|
||||
case RS_INVAL_HORIZON:
|
||||
values[i++] = CStringGetTextDatum(SLOT_INVAL_HORIZON_TEXT);
|
||||
break;
|
||||
|
||||
case RS_INVAL_WAL_LEVEL:
|
||||
values[i++] = CStringGetTextDatum(SLOT_INVAL_WAL_LEVEL_TEXT);
|
||||
break;
|
||||
}
|
||||
if (cause == RS_INVAL_NONE)
|
||||
nulls[i++] = true;
|
||||
else
|
||||
values[i++] = CStringGetTextDatum(SlotInvalidationCauses[cause]);
|
||||
}
|
||||
|
||||
values[i++] = BoolGetDatum(slot_contents.data.failover);
|
||||
|
||||
Reference in New Issue
Block a user