From ee6d81915a9c5fa2160b14439d1d76692cfebaf7 Mon Sep 17 00:00:00 2001
From: Amit Kapila <akapila@postgresql.org>
Date: Fri, 16 Jul 2021 10:55:59 +0530
Subject: [PATCH v4 2/2] Update comments for AlterSubscription.

Add explanation as to why the subscription needs to be disabled to allow
slot_name as none.

Author: Japin Li and Amit Kapila
Discussion: https://postgr.es/m/MEYP282MB1669CBD98E721C77CA696499B61A9@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM
---
 src/backend/commands/subscriptioncmds.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c
index fb0b0058f2..41c8397902 100644
--- a/src/backend/commands/subscriptioncmds.c
+++ b/src/backend/commands/subscriptioncmds.c
@@ -912,6 +912,13 @@ AlterSubscription(AlterSubscriptionStmt *stmt, bool isTopLevel)
 
 				if (IsSet(opts.specified_opts, SUBOPT_SLOT_NAME))
 				{
+					/*
+					 * The subscription must be disabled to allow slot_name as
+					 * 'none', otherwise, the apply worker will repeatedly try
+					 * to stream the data using that slot_name which neither
+					 * exists on the publisher nor the user will be allowed to
+					 * create it.
+					 */
 					if (sub->enabled && !opts.slot_name)
 						ereport(ERROR,
 								(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
-- 
2.28.0.windows.1

