Re: row filtering for logical replication - Mailing list pgsql-hackers

From Greg Nancarrow
Subject Re: row filtering for logical replication
Date
Msg-id CAJcOf-fR_BKHNuz7AXCWuk40ESVOr=DkXf3evbNNi4M4V_5agQ@mail.gmail.com
Whole thread Raw
In response to RE: row filtering for logical replication  ("houzj.fnst@fujitsu.com" <houzj.fnst@fujitsu.com>)
Responses Re: row filtering for logical replication
List pgsql-hackers
On Mon, Jan 31, 2022 at 1:12 PM houzj.fnst@fujitsu.com
<houzj.fnst@fujitsu.com> wrote:
>
> > > +   /*
> > > +    * We need this map to avoid relying on ReorderBufferChangeType
> > enums
> > > +    * having specific values.
> > > +    */
> > > +   static int map_changetype_pubaction[] = {
> > > +           [REORDER_BUFFER_CHANGE_INSERT] = PUBACTION_INSERT,
> > > +           [REORDER_BUFFER_CHANGE_UPDATE] = PUBACTION_UPDATE,
> > > +           [REORDER_BUFFER_CHANGE_DELETE] = PUBACTION_DELETE
> > > +   };
> >
> > Why is this "static"? Function-local statics only really make sense for variables
> > that are changed and should survive between calls to a function.
>
> Removed the "static" label.
>

This array was only ever meant to be read-only, and visible only to
that function.
IMO removing "static" makes things worse because now that array gets
initialized each call to the function, which is unnecessary.
I think it should just be: "static const int map_changetype_pubaction[] = ..."

Regards,
Greg Nancarrow
Fujitsu Australia



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Latest LLVM breaks our code again
Next
From: Dilip Kumar
Date:
Subject: Re: [BUG]Update Toast data failure in logical replication