diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c
index 304ac84..29e6da5 100644
--- a/src/backend/commands/subscriptioncmds.c
+++ b/src/backend/commands/subscriptioncmds.c
@@ -37,6 +37,7 @@
 
 #include "replication/logicallauncher.h"
 #include "replication/origin.h"
+#include "replication/slot.h"
 #include "replication/walreceiver.h"
 #include "replication/walsender.h"
 #include "replication/worker_internal.h"
@@ -316,6 +317,9 @@ CreateSubscription(CreateSubscriptionStmt *stmt, bool isTopLevel)
 				(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
 				 (errmsg("must be superuser to create subscriptions"))));
 
+	if (slotname_given)
+		ReplicationSlotValidateName(slotname, ERROR);
+
 	rel = heap_open(SubscriptionRelationId, RowExclusiveLock);
 
 	/* Check if name is used */
@@ -630,6 +634,8 @@ AlterSubscription(AlterSubscriptionStmt *stmt)
 								(errcode(ERRCODE_SYNTAX_ERROR),
 								 errmsg("cannot set slot_name = NONE for enabled subscription")));
 
+					ReplicationSlotValidateName(slotname, ERROR);
+
 					if (slotname)
 						values[Anum_pg_subscription_subslotname - 1] =
 						DirectFunctionCall1(namein, CStringGetDatum(slotname));
