Re: PublicationActions - use bit flags.

2022-01-25 Thread Peter Eisentraut
On 25.01.22 07:14, Greg Nancarrow wrote: On Tue, Jan 25, 2022 at 7:31 AM Peter Eisentraut > wrote: > > Why can't GetRelationPublicationActions() have the PublicationActions as > a return value, instead of changing it to an output argument? That wou

Re: PublicationActions - use bit flags.

2022-01-24 Thread Greg Nancarrow
On Tue, Jan 25, 2022 at 7:31 AM Peter Eisentraut < peter.eisentr...@enterprisedb.com> wrote: > > Why can't GetRelationPublicationActions() have the PublicationActions as > a return value, instead of changing it to an output argument? That would be OK too, for now, for the current (small size, typi

Re: PublicationActions - use bit flags.

2022-01-24 Thread Peter Eisentraut
On 21.01.22 01:05, Greg Nancarrow wrote: On Tue, Dec 21, 2021 at 12:55 PM Greg Nancarrow wrote: On Tue, Dec 21, 2021 at 11:56 AM Tom Lane wrote: Removing this is not good: if (relation->rd_pubactions) - { pfree(relation->rd_pubactions); - rel

Re: PublicationActions - use bit flags.

2022-01-20 Thread Greg Nancarrow
On Tue, Dec 21, 2021 at 12:55 PM Greg Nancarrow wrote: > > On Tue, Dec 21, 2021 at 11:56 AM Tom Lane wrote: > > > > Removing this is not good: > > > > if (relation->rd_pubactions) > > - { > > pfree(relation->rd_pubactions); > > - relation->rd_pubactions

Re: PublicationActions - use bit flags.

2021-12-29 Thread Tom Lane
Peter Smith writes: > On Thu, Dec 30, 2021 at 3:30 AM Justin Pryzby wrote: >> + 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 assignm

Re: PublicationActions - use bit flags.

2021-12-29 Thread Peter Smith
On Thu, Dec 30, 2021 at 3:30 AM Justin Pryzby 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

Re: PublicationActions - use bit flags.

2021-12-29 Thread Justin Pryzby
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 i

Re: PublicationActions - use bit flags.

2021-12-28 Thread Peter Smith
On Tue, Dec 21, 2021 at 11:56 AM Tom Lane wrote: > > Greg Nancarrow writes: > > I've attached a patch which addresses that and replaces a couple of > > memcpy()s with struct assignment, as suggested. > > Removing this is not good: > > if (relation->rd_pubactions) > - { >

Re: PublicationActions - use bit flags.

2021-12-20 Thread Greg Nancarrow
On Tue, Dec 21, 2021 at 11:56 AM Tom Lane wrote: > > Removing this is not good: > > if (relation->rd_pubactions) > - { > pfree(relation->rd_pubactions); > - relation->rd_pubactions = NULL; > - } > > If the subsequent palloc fails, you've created a

Re: PublicationActions - use bit flags.

2021-12-20 Thread Tom Lane
Greg Nancarrow writes: > I've attached a patch which addresses that and replaces a couple of > memcpy()s with struct assignment, as suggested. Removing this is not good: if (relation->rd_pubactions) - { pfree(relation->rd_pubactions); - relation->rd_pu

Re: PublicationActions - use bit flags.

2021-12-20 Thread Greg Nancarrow
On Tue, Dec 21, 2021 at 4:14 AM Alvaro Herrera wrote: > > On 2021-Dec-20, Peter Eisentraut wrote: > > > I don't see why this is better. It just makes the code longer and adds more > > punctuation and reduces type safety. > > Removing one palloc is I think the most important consequence ... > prob

Re: PublicationActions - use bit flags.

2021-12-20 Thread Alvaro Herrera
On 2021-Dec-20, Peter Eisentraut wrote: > I don't see why this is better. It just makes the code longer and adds more > punctuation and reduces type safety. Removing one palloc is I think the most important consequence ... probably not a big deal though. I think we could change the memcpy calls

Re: PublicationActions - use bit flags.

2021-12-20 Thread Tom Lane
Peter Eisentraut writes: > On 20.12.21 01:18, Peter Smith wrote: >> 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. > I don't see why this is better.

Re: PublicationActions - use bit flags.

2021-12-20 Thread Peter Eisentraut
On 20.12.21 01:18, 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

Re: PublicationActions - use bit flags.

2021-12-19 Thread Greg Nancarrow
On Mon, Dec 20, 2021 at 11:19 AM 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