The command succeed even if slot_name is invalid. That's because slot_name isn't validated. ReplicationSlotValidateName() should be called in parse_subscription_options() to avoid a pilot error. IMHO we should prevent a future error (use of invalid slot name).
Of course `test slot` doesn't exist, because I can't create a slot with
incorrect name. And consequently I can't drop this subscription:
=# DROP SUBSCRIPTION test_sub;
ERROR: XX000: could not drop the replication slot "test slot" on publisher
DETAIL: The error was: ERROR: replication slot name "test slot" contains invalid character
HINT: Replication slot names may only contain lower case letters, numbers, and the underscore character.
Indeed you can drop the subscription. There are two details: (i) subscription should be disabled and (ii) slot name can't be set.
bar=# drop subscription sub1; ERROR: could not drop the replication slot "does_not_exist" on publisher DETAIL: The error was: ERROR: replication slot "does_not_exist" does not exist bar=# alter subscription sub1 set (slot_name = NONE); ERROR: cannot set slot_name = NONE for enabled subscription bar=# alter subscription sub1 disable; ALTER SUBSCRIPTION bar=# drop subscription sub1; ERROR: could not drop the replication slot "does_not_exist" on publisher DETAIL: The error was: ERROR: replication slot "does_not_exist" does not exist bar=# alter subscription sub1 set (slot_name = NONE); ALTER SUBSCRIPTION bar=# drop subscription sub1; DROP SUBSCRIPTION
Should we add a hint for 'could not drop the replication slot' message?