0001-Fix-check_pub_rdt-bypass-when-origin-is-set-in-same-.patch

application/octet-stream

Filename: 0001-Fix-check_pub_rdt-bypass-when-origin-is-set-in-same-.patch
Type: application/octet-stream
Part: 0
Message: [Patch] Fix check_pub_rdt bypass when origin is set in same ALTER SUBSCRIPTION
From 256a875eb10c4831cbf539537cd86ca3a2c9c0ef Mon Sep 17 00:00:00 2001
From: Satya Narlapuram <satyanarlapuram@gmail.com>
Date: Tue, 26 May 2026 22:45:56 +0000
Subject: [PATCH v1 1/2] Fix check_pub_rdt bypass when origin is set in same
 ALTER SUBSCRIPTION

When ALTER SUBSCRIPTION SET (retain_dead_tuples = true, origin = 'none')
is used, the publisher version/recovery check was bypassed because the
origin handling unconditionally overwrote check_pub_rdt to false.

Fix by using |= instead of = so that the flag set by retain_dead_tuples
cannot be cleared by a subsequent origin assignment in the same command.
---
 src/backend/commands/subscriptioncmds.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/backend/commands/subscriptioncmds.c b/src/backend/commands/subscriptioncmds.c
index 523959ba0ce..2c1a85886a0 100644
--- a/src/backend/commands/subscriptioncmds.c
+++ b/src/backend/commands/subscriptioncmds.c
@@ -1748,9 +1748,11 @@ AlterSubscription(ParseState *pstate, AlterSubscriptionStmt *stmt,
 					/*
 					 * Check if changes from different origins may be received
 					 * from the publisher when the origin is changed to ANY
-					 * and retain_dead_tuples is enabled.
+					 * and retain_dead_tuples is enabled.  Use |= so that we
+					 * don't clear the flag already set when retain_dead_tuples
+					 * was changed in the same command.
 					 */
-					check_pub_rdt = retain_dead_tuples &&
+					check_pub_rdt |= retain_dead_tuples &&
 						pg_strcasecmp(opts.origin, LOGICALREP_ORIGIN_ANY) == 0;
 
 					origin = opts.origin;
-- 
2.43.0