Re: pgsql: Remove useless default clause in switch - Mailing list pgsql-committers

From Alvaro Herrera
Subject Re: pgsql: Remove useless default clause in switch
Date
Msg-id 20180424015058.yx7vtksqzjarzkrd@alvherre.pgsql
Whole thread Raw
In response to Re: pgsql: Remove useless default clause in switch  (David Rowley <david.rowley@2ndquadrant.com>)
Responses Re: pgsql: Remove useless default clause in switch  (David Rowley <david.rowley@2ndquadrant.com>)
List pgsql-committers
David Rowley wrote:
> On 24 April 2018 at 03:12, Alvaro Herrera <alvherre@alvh.no-ip.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.

> 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.

Yeah, operator strategy numbers are a hopeless case, because each index
AM defines its own set of valid strategy numbers.  Another interesting
case is PARTITION_STRATEGY which I wanted to convert to an enum, but got
sidetracked.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


pgsql-committers by date:

Previous
From: Amit Langote
Date:
Subject: Re: pgsql: Remove useless default clause in switch
Next
From: David Rowley
Date:
Subject: Re: pgsql: Remove useless default clause in switch