Re: Use the enum value CRS_EXPORT_SNAPSHOT instead of "0" - Mailing list pgsql-hackers

From Peter Smith
Subject Re: Use the enum value CRS_EXPORT_SNAPSHOT instead of "0"
Date
Msg-id CAHut+PubXmw8P-XLj0D0C99hScohHZ5JcnwuBjQ7qWGBUe5yCg@mail.gmail.com
Whole thread Raw
In response to Re: Use the enum value CRS_EXPORT_SNAPSHOT instead of "0"  (Masahiko Sawada <sawada.mshk@gmail.com>)
List pgsql-hackers
On Fri, Jun 16, 2023 at 6:17 PM Masahiko Sawada <sawada.mshk@gmail.com> wrote:
>
> On Fri, Jun 16, 2023 at 3:10 PM Wei Wang (Fujitsu)
> <wangw.fnst@fujitsu.com> wrote:
> >
> > Hi,
> >
> > In the function WalReceiverMain, when the function walrcv_create_slot is called,
> > the fourth parameter is assigned the value "0" instead of the enum value
> > "CRS_EXPORT_SNAPSHOT". I think it would be better to use the corresponding enum
> > value.
>
> The walreceiver process doesn't use CRS_EXPORT_SNAPSHOT actually,
> right? I think replacing it with CRS_EXPORT_SNAPSHOT would rather
> confuse me
>

Passing some number (0) which has the same value as an enum, while at
the same time not intending it to have the same meaning as that enum
smells strange to me.

If none of the existing enums is meaningful here, then perhaps there
ought to be another enum added  (CRS_UNUSED?) and pass that instead.

~

Alternatively, maybe continue to pass 0, but ensure the existing enums
do not include any value of 0.

e.g.
typedef enum
{
    CRS_EXPORT_SNAPSHOT = 1,
    CRS_NOEXPORT_SNAPSHOT,
    CRS_USE_SNAPSHOT
} CRSSnapshotAction;

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



pgsql-hackers by date:

Previous
From: Quan Zongliang
Date:
Subject: Incorrect estimation of HashJoin rows resulted from inaccurate small table statistics
Next
From: Alvaro Herrera
Date:
Subject: Re: Use the enum value CRS_EXPORT_SNAPSHOT instead of "0"