Re: pgsql: Remove useless default clause in switch

From: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: Re: pgsql: Remove useless default clause in switch
Date: 2018-04-24 01:53:32
Message-ID: CAKJS1f9xM4dwZDaTEwcFgOsGx-fOkOoD-7xgNxCxGC5dyN9u=g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

On 24 April 2018 at 13:50, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> wrote:
> David Rowley wrote:
>> On 24 April 2018 at 03:12, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> wrote:
>> > Remove useless default clause in switch
>> >
>> > The switch covers all values of the enum driver variable, so having a
>> > default: clause is useless, even if it's only to do Assert(false).
>>
>> Just for my own understanding:
>>
>> 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.
>
> The compiler will emit a warning when it sees that not all cases are
> handled, so it's not necessary to have a default case.

Thank you all for explaining that. It very much makes sense now.

--
David Rowley http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Browse pgsql-committers by date

  From Date Subject
Next Message Alvaro Herrera 2018-04-24 17:04:06 pgsql: Initialize ExprStates once in run-time partition pruning
Previous Message Alvaro Herrera 2018-04-24 01:50:58 Re: pgsql: Remove useless default clause in switch