Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xNi92-00000002hVR-1kQD for pgsql-hackers@arkaria.postgresql.org; Mon, 02 Nov 2026 02:51:37 +0000 Received: from localhost ([127.0.0.1]:46020 helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xNi91-0000000160m-2fB4 for pgsql-hackers@arkaria.postgresql.org; Mon, 02 Nov 2026 02:51:35 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]:46204) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xNi91-0000000160d-19rj for pgsql-hackers@lists.postgresql.org; Mon, 02 Nov 2026 02:51:35 +0000 Received: from mail-dl2-x04.google.com ([2607:f8b0:4864:38::4]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1xNi8z-000000029wn-0cI7 for pgsql-hackers@lists.postgresql.org; Mon, 02 Nov 2026 02:51:34 +0000 Received: by mail-dl2-x04.google.com with SMTP id a92af1059eb24-1949fbcbe6cso232246c88.1 for ; Sun, 01 Nov 2026 18:51:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1793587890; x=1794192690; darn=lists.postgresql.org; h=content-transfer-encoding:content-type:in-reply-to:from:references :cc:to:subject:user-agent:mime-version:date:message-id:from:to:cc :subject:date:message-id:reply-to:content-type; bh=vq6fA8RvtmhM/XnrRKBUPxBSwbO2Ub9naCLK339X1/g=; b=F3QkDosnrAVHFqMqeOfeC5BVZUiDWFITRqIXL/n9+l/ZYoaTFM9UkYAWl9Z5f3LmpH UoKeNLCyifKLUoJqhcZ6WI+BbfRMEyXU3/ssxlncidaSBjXsl3MLvdDZ4dxk9Kdq/vTX cBAyW9zyefCjizJlvRnyRk/7rV79myd6vxZmJ1XbP2w1lY0raS7KkBRnHFxL3JbeIaXh /OiS+ec+JSBTKcA8G2B0reUvF25Hz+lByBKywKVEC4rn0Y3fNRe++fK4Jzkj30uNugzO iDAWHNABqi7i5vOAXUTGojLLB3aHjsnfA00Wv4Eg4NIjylRi8fyroWdfXkSDtBZYGl3C YB7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1793587890; x=1794192690; h=content-transfer-encoding:content-type:in-reply-to:from:references :cc:to:subject:user-agent:mime-version:date:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=vq6fA8RvtmhM/XnrRKBUPxBSwbO2Ub9naCLK339X1/g=; b=aE6jXpG6SZqN+gBwsLNAh178dDSAz1SlbRbtgg21YtTawcl9qToSclf5vrtEnDDjSo XGl10FLevbvmgU9GK+1X/MWqm/0nJVt26rgc4XNVtkt5BiPQIjTk0+JD00K+RwkgJ/Xw 9E8PwoKpeuQPM7j0AZKjtpUJzILicQejR24r3JtLafg70UUfZad7o61pi0GcjzcEkkKY qRgoxZbKcjkmpFGr0Q2chLXf6aY2iUmoKUKQY92m3/lWCqDHpoXwNVu0b8kApTkNdJ1s BOQko7R52eIu9nTHssjsJRBamxiOWNrM3JyIcu1wjTC889h55HHgU/1JYLXKGvkOElSC rYcw== X-Forwarded-Encrypted: i=1; AKwUvBwYhkZ37ZnAa7Ba0AUcrgXrxyXLxUwWzrM7cZA2xrNTp1EZeCKWU88vcF9GSwdIq4tvIkPdNLrYQCarSVUQ@lists.postgresql.org X-Gm-Message-State: AFq9FYJi4KWSXDkdqQrzl0P7wyvzsKm0Li9wHpgdCmH2MBOJrB5qSTnB kQ5xnep7y68kHcLkPJhNPo0OQaXMeMdXE2EUwbG+H3Ow9IXiFYoRe3yu X-Gm-Gg: AYBFou3lWYsMslPb0cfoRgi90ezjvegIOOA631+v6RMc0yKWdLYGWrm629AbgbTBYXU PKMFUk3E3Ks2K93cGYZjwlJzf0GJV20RGkyet4q5yf/EXrb1lnpT+RtfZvbF+kD2QQtsa3hmwyV k9tDXGHNEuU7rI/RRw7V/XlS4B7l0a3h6rqWajOHh+8+jiP0v+6kBXoV8OITGBaltjfhtNZ4HOh rawx/GjYy2OVhNs4pB5VH4BAlIY+2rorK996lGN14DLwtAP3uOnXKnCaNM1WP0XvUX/RWSs8+Q8 ysiHSU7bIX0e1bNTSgpZWeL8aFVRYSyQZy8pzSNs43hm1RVFaAD6oR7kZ+OktXWrL+WgamSLdmz pj+xNKu25HI5STd+snQAMsVTZgUcbEnrmPUZs6dZISX6eoDvmsH7qhY1iehURyRirbebIZIF6Ey pfLsFWGmRGUItNwiNFdkruyxHYOEEpi2F1VfcG3G780lxOK81k/aPW6iYpISP369Km2gT4V92N3 OcCt+sCeRgvrrrBwZ+AE6nb4zKmk4Ulzp+jr2GoqziZaIf6lQzJGN75vWBFDA7AoJ/4cLEpLL/Y KAW7PF+awZQtjMaPQIz+M0mgv/WbBDOwstkpZDF4W15eoVi+5YeCXAXcWYifnRYA1aINxsIK/8p QaZR+vG+3zcadzKNg+qQOxngjuUR733BW5RRUVk2vWUfIQx1Qa3UyM/PlXwfRS7b8CqEX+y0iT8 DE8DpkF2eoTJ+z7GhkpcVUw0siPP18xcZbQgm1FEu1/iH8DPcmBa1FI08= X-Received: by 2002:a05:7022:1509:b0:151:f0c5:7a09 with SMTP id a92af1059eb24-1ac5e22adbamr15578899c88.43.1793587889865; Sun, 01 Nov 2026 18:51:29 -0800 (PST) Received: from ?IPV6:2400:79c0:20d:180:298a:7777:d98e:58c0? ([2403:300:600d:d80:3647:7777:d98e:58c0]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1ac13ef1a16sm26760853c88.1.2026.11.01.18.51.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 01 Nov 2026 18:51:29 -0800 (PST) Message-ID: <69baee13-4c0f-4c00-a268-2bff2b8246f9@gmail.com> Date: Mon, 2 Nov 2026 10:51:25 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Avoid resetting subscription two_phase state to pending when already enabled To: Peter Smith Cc: shveta malik , pgsql-hackers@lists.postgresql.org, amit.kapila16@gmail.com, shveta malik References: <8e85abdf-738b-4578-ac42-4dc8eaa061dd@gmail.com> <3ba34b9c-455e-487c-9815-8a7f31297065@gmail.com> From: Zhijie Hou In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Mon, Nov 2, 2026 at 10:04 AM Peter Smith wrote: > IMO, the nested checking of opts.twophase in the ternary makes the > patch code unnecessarily hard to follow across combinations. > > My suggestion is to implement it using more verbose, but easier-to-read code: > > /* Change system catalog accordingly */ > if (sub->twophasestate == LOGICALREP_TWOPHASE_STATE_DISABLED) > { > if (opts.twophase) > { > /* enable two_phase */ > values[Anum_pg_subscription_subtwophasestate - 1] = > CharGetDatum(LOGICALREP_TWOPHASE_STATE_PENDING); > replaces[Anum_pg_subscription_subtwophasestate - 1] = true; > } > } > else if (!opts.twophase) > { > /* disable two_phase */ > values[Anum_pg_subscription_subtwophasestate - 1] = > CharGetDatum(LOGICALREP_TWOPHASE_STATE_DISABLED); > replaces[Anum_pg_subscription_subtwophasestate - 1] = true; > } > > ~ Thank for the suggestion, but I personally don't prefer the longer, nested style, as I don't find it clearly easier to read. So I would keep the current version for now and see what the committer thinks. -- Best Regards, Zhijie Hou