diff options
author | Michael Paquier | 2024-02-21 23:40:40 +0000 |
---|---|---|
committer | Michael Paquier | 2024-02-21 23:40:40 +0000 |
commit | 943f7ae1c8693cf3ea59d103aaf9590ea062fb9c (patch) | |
tree | bfcb1e6e45ec5516a915bb87dcceb0b805723fb1 /src/include | |
parent | 28f3915b73f75bd1b50ba070f56b34241fe53fd1 (diff) |
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 74a730631065, 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
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/replication/slot.h | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/include/replication/slot.h b/src/include/replication/slot.h index e706ca834c0..acbf567150e 100644 --- a/src/include/replication/slot.h +++ b/src/include/replication/slot.h @@ -40,6 +40,9 @@ typedef enum ReplicationSlotPersistency /* * Slots can be invalidated, e.g. due to max_slot_wal_keep_size. If so, the * 'invalidated' field is set to a value other than _NONE. + * + * When adding a new invalidation cause here, remember to update + * SlotInvalidationCauses and RS_INVAL_MAX_CAUSES. */ typedef enum ReplicationSlotInvalidationCause { @@ -52,13 +55,7 @@ typedef enum ReplicationSlotInvalidationCause RS_INVAL_WAL_LEVEL, } ReplicationSlotInvalidationCause; -/* - * The possible values for 'conflict_reason' returned in - * pg_get_replication_slots. - */ -#define SLOT_INVAL_WAL_REMOVED_TEXT "wal_removed" -#define SLOT_INVAL_HORIZON_TEXT "rows_removed" -#define SLOT_INVAL_WAL_LEVEL_TEXT "wal_level_insufficient" +extern PGDLLIMPORT const char *const SlotInvalidationCauses[]; /* * On-Disk data of a replication slot, preserved across restarts. @@ -275,6 +272,6 @@ extern void CheckPointReplicationSlots(bool is_shutdown); extern void CheckSlotRequirements(void); extern void CheckSlotPermissions(void); extern ReplicationSlotInvalidationCause - GetSlotInvalidationCause(char *conflict_reason); + GetSlotInvalidationCause(const char *conflict_reason); #endif /* SLOT_H */ |