Re: PublicationActions - use bit flags.

From: Peter Smith <smithpb2250(at)gmail(dot)com>
To: Justin Pryzby <pryzby(at)telsasoft(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: PublicationActions - use bit flags.
Date: 2021-12-30 00:31:53
Message-ID: CAHut+PtZ-OxSN_nPohqv389=iRyw78S87nv2XCeF8LwafbQgew@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Dec 30, 2021 at 3:30 AM Justin Pryzby <pryzby(at)telsasoft(dot)com> wrote:
>
> On Mon, Dec 20, 2021 at 11:18:41AM +1100, Peter Smith wrote:
> > For some reason the current HEAD PublicationActions is a struct of
> > boolean representing combinations of the 4 different "publication
> > actions".
> >
> > I felt it is more natural to implement boolean flag combinations using
> > a bitmask instead of a struct of bools. IMO using the bitmask also
> > simplifies assignment and checking of said flags.
>
> Peter E made a suggestion to use a similar struct with bools last year for
> REINDEX.
> https://www.postgresql.org/message-id/7ec67c56-2377-cd05-51a0-691104404abe@enterprisedb.com
>
> Alvaro pointed out that the integer flags are better for ABI compatibility - it
> would allow adding a new flag in backbranches, if that were needed for a
> bugfix.
>
> But that's not very compelling, since the bools have existed in v10...
> Also, the booleans directly correspond with the catalog.
>
> + if (pubform->pubinsert) pub->pubactions |= PUBACTION_INSERT;
>
> This is usually written like:
>
> pub->pubactions |= (pubform->pubinsert ? PUBACTION_INSERT : 0)
>

Thanks for the info, I've modified those assignment styles as suggested.

------
Kind Regards,
Peter Smith.
Fujitsu Australia.

Attachment Content-Type Size
v3-0001-PublicationActions-use-bit-flags.patch application/octet-stream 15.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2021-12-30 00:36:32 Re: PublicationActions - use bit flags.
Previous Message Alvaro Herrera 2021-12-30 00:15:08 Re: Column Filtering in Logical Replication