Re: Enumize logical replication message actions

Ashutosh Bapat <ashutosh.bapat@2ndquadrant.com>

From: Ashutosh Bapat <ashutosh.bapat@2ndquadrant.com>
To: Amit Kapila <amit.kapila16@gmail.com>
Cc: Peter Smith <smithpb2250@gmail.com>, Kyotaro Horiguchi <horikyota.ntt@gmail.com>, Alvaro Herrera <alvherre@alvh.no-ip.org>, Andres Freund <andres@anarazel.de>, Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2020-10-30T11:36:57Z
Lists: pgsql-hackers
On Fri, 30 Oct 2020 at 14:59, Amit Kapila <amit.kapila16@gmail.com> wrote:

> On Fri, Oct 30, 2020 at 11:50 AM Amit Kapila <amit.kapila16@gmail.com>
> wrote:
> >
> > On Fri, Oct 30, 2020 at 10:37 AM Peter Smith <smithpb2250@gmail.com>
> wrote:
> > >
> > > IIUC getting rid of the default from the switch can make the missing
> > > enum detection easier because then you can use -Wswitch option to
> > > expose the problem (instead of -Wswitch-enum which may give lots of
> > > false positives as well)
> > >
> >
> > Fair enough. So, it makes sense to move the default out of the switch
> case.
> >
>
> One more thing I was thinking about this patch was whether it has any
> impact w.r.t to Endianness as we are using four-bytes to represent
> one-byte and it seems there is no issue with that because pq_sendbyte
> accepts just one-byte and sends that over the network. So, we could
> see a problem only if we use any enum value which is more than
> one-byte which we are anyway adding a warning message along with the
> definition of enum. So, we are safe here. Does that make sense?
>
>
yes. Endian-ness should be handled by the compiler transparently.

-- 
Best Wishes,
Ashutosh

Commits

  1. Use Enums for logical replication message types at more places.

  2. Use Enum for top level logical replication message types.