Hi,
> copy_replication_slot() scans ReplicationSlotCtl->replication_slots[]
> itself to find the source slot. SearchNamedReplicationSlot() performs
> exactly that lookup, and the caller already holds
> ReplicationSlotControlLock, so it can be called with
> need_lock = false.
This looks a good improvement.
But isn't it better to check whether the slot exists, before acquiring the
spinlock like [1]? This can clarify the normal/abnormal case.
> pg_get_replication_slots() compares slot_contents.data.database with
> InvalidOid three times to distinguish physical from logical slots.
> SlotIsPhysical() expresses the same condition, and the same function
> already uses this macro elsewhere.
One comment:
```
- if (slot_contents.data.database == InvalidOid)
+ if (SlotIsPhysical(&slot_contents))
nulls[i++] = true;
else
values[i++] = NameGetDatum(&slot_contents.data.plugin);
```
Not sure, isn't it clearer to check slot_contents.data.plugin?
[1]:
```
src = SearchNamedReplicationSlot(NameStr(*src_name), false);
if (!src)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("replication slot \"%s\" does not
exist", NameStr(*src_name))));
/* Copy the slot contents while holding spinlock */
SpinLockAcquire(&src->mutex);
first_slot_contents = *src;
SpinLockRelease(&src->mutex);
```
Best regards,
Hayato Kuroda
FUJITSU LIMITED