Hi, A subscription with a name that isn't a valid slot name can be created with connect = false, because the default slot name (the subscription name) is not validated:
CREATE SUBSCRIPTION "MySub" CONNECTION 'dbname=postgres'
PUBLICATION p WITH (connect = false);
pg_dump always writes the slot name explicitly, and an explicit
slot_name is validated, so the restore fails:
CREATE SUBSCRIPTION "MySub" CONNECTION 'dbname=postgres' PUBLICATION p
WITH (connect = false, slot_name = 'MySub', streaming = parallel);
ERROR: replication slot name "MySub" contains invalid character
pg_upgrade fails the same way.
The attached patch makes pg_dump leave slot_name out when it equals the
subscription name, so the restore applies the same default.
One case it doesn't cover: a subscription renamed after creation keeps
its old slot name, which then gets written explicitly. Fixing that
would mean not validating slot_name locally when connect = false.
Thoughts?
Regards,
Baji Shaik
0001-pg_dump-Don-t-dump-a-subscription-s-default-slot-nam.patch
Description: Binary data
