Re: PublicationActions - use bit flags. - Mailing list pgsql-hackers

From Justin Pryzby
Subject Re: PublicationActions - use bit flags.
Date
Msg-id 20211229163014.GO24477@telsasoft.com
Whole thread Raw
In response to PublicationActions - use bit flags.  (Peter Smith <smithpb2250@gmail.com>)
Responses Re: PublicationActions - use bit flags.  (Peter Smith <smithpb2250@gmail.com>)
List pgsql-hackers
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)

-- 
Justin



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Report checkpoint progress in server logs
Next
From: "Imseih (AWS), Sami"
Date:
Subject: Re: Add index scan progress to pg_stat_progress_vacuum