pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Zhijie Hou <houzhijie22@gmail.com>
To: Peter Smith <smithpb2250@gmail.com>
Cc: shveta malik <shveta.malik@gmail.com>
Cc: pgsql-hackers@lists.postgresql.org, amit.kapila16@gmail.com, shveta malik <shvetamalik@gmail.com>
Subject: Re: Avoid resetting subscription two_phase state to pending when already enabled
Date: Mon, 2 Nov 2026 10:51:25 +0800
Message-ID: <69baee13-4c0f-4c00-a268-2bff2b8246f9@gmail.com> (raw)
In-Reply-To: <CAHut+PsCwRwgLFrkGK5j=JHBtaebUf9aNo=HF4eqRJd7eifbsQ@mail.gmail.com>
References: <8e85abdf-738b-4578-ac42-4dc8eaa061dd@gmail.com>
	<CAJpy0uBnm2TkxZ3DQcjUqrXUzz07ojkeFamz6Oh=rv8JZwLr9w@mail.gmail.com>
	<3ba34b9c-455e-487c-9815-8a7f31297065@gmail.com>
	<CAHut+PsCwRwgLFrkGK5j=JHBtaebUf9aNo=HF4eqRJd7eifbsQ@mail.gmail.com>

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






view thread (18+ messages)  latest in thread

Message-ID: <69baee13-4c0f-4c00-a268-2bff2b8246f9@gmail.com>
Permalink:  ../69baee13-4c0f-4c00-a268-2bff2b8246f9@gmail.com/
Also on:    postgresql.org/message-id/69baee13-4c0f-4c00-a268-2bff2b8246f9@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: houzhijie22@gmail.com, smithpb2250@gmail.com, shveta.malik@gmail.com, shvetamalik@gmail.com
  Subject: Re: Avoid resetting subscription two_phase state to pending when already enabled
  In-Reply-To: <69baee13-4c0f-4c00-a268-2bff2b8246f9@gmail.com>
  References: <8e85abdf-738b-4578-ac42-4dc8eaa061dd@gmail.com> <CAJpy0uBnm2TkxZ3DQcjUqrXUzz07ojkeFamz6Oh=rv8JZwLr9w@mail.gmail.com> <3ba34b9c-455e-487c-9815-8a7f31297065@gmail.com> <CAHut+PsCwRwgLFrkGK5j=JHBtaebUf9aNo=HF4eqRJd7eifbsQ@mail.gmail.com> <69baee13-4c0f-4c00-a268-2bff2b8246f9@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox