Re: pgsql: Remove useless default clause in switch

From: Amit Langote <Langote_Amit_f8(at)lab(dot)ntt(dot)co(dot)jp>
To: Michael Paquier <michael(at)paquier(dot)xyz>, David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
Cc: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: Re: pgsql: Remove useless default clause in switch
Date: 2018-04-24 01:25:59
Message-ID: 55ab8ed8-818f-5981-66da-80483282789f@lab.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

On 2018/04/24 10:20, Michael Paquier wrote:
> On Tue, Apr 24, 2018 at 12:27:27PM +1200, David Rowley wrote:
>> I always thought that when all options were covered that we generally
>> kept a default just in case someone added another enum and forgot to
>> update the code.
>>
>> I know generally those are with elog ERRORs but both would be designed
>> to alert a programmer, just at different times.
>
> The advantage with what Alvaro has done is that you get warning at
> compilation time, so it is much more helpful for developers when
> adding an option because they need to think about code paths where the
> warning comes from.

+1

>> There are other examples in that file with the switch
>> (part_scheme->strategy), these are not using enums. I'd have to assume
>> that these must be different because of that.
>
> Those apply to PARTITION_STRATEGY_LIST and such, which are not defined
> based on an enumeration but using their catalog interpretation, so this
> assumption cannot apply. The same applies for BTLessEqualStrategyNumber
> & friends which have their own definition.
>
> You are right for what's in perform_pruning_combine_step though, so the
> attached could also be applied.

Thanks for spotting that one.

Regards,
Amit

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Alvaro Herrera 2018-04-24 01:50:58 Re: pgsql: Remove useless default clause in switch
Previous Message Michael Paquier 2018-04-24 01:20:42 Re: pgsql: Remove useless default clause in switch