| From: | Peter Smith <smithpb2250(at)gmail(dot)com> |
|---|---|
| To: | Zhijie Hou <houzhijie22(at)gmail(dot)com> |
| Cc: | shveta malik <shveta(dot)malik(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, amit(dot)kapila16(at)gmail(dot)com, shveta malik <shvetamalik(at)gmail(dot)com> |
| Subject: | Re: Avoid resetting subscription two_phase state to pending when already enabled |
| Date: | 2026-11-02 02:04:07 |
| Message-ID: | CAHut+PsCwRwgLFrkGK5j=JHBtaebUf9aNo=HF4eqRJd7eifbsQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
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;
}
~
This way also avoids redundant replacements like 'd' to 'd', 'p' to 'p', etc.
======
Kind Regards,
Peter Smith.
Fujitsu Australia
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Chao Li | 2026-11-02 02:05:21 | Re: [PATCH] pgcrypto: Fix sha-crypt rounds= values that do not fit in int (BUG #19743) |
| Previous Message | Fujii Masao | 2026-11-02 01:57:15 | Re: Remove unused arguments from split_selfjoin_quals() |