pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
To: David Rowley <david.rowley@2ndquadrant.com>
Cc: pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Remove useless default clause in switch
Date: Mon, 23 Apr 2018 22:50:58 -0300
Message-ID: <20180424015058.yx7vtksqzjarzkrd@alvherre.pgsql> (raw)
In-Reply-To: <CAKJS1f9vS7W0MDp-DJ0ixg3bMhJo0vdU-vzjZR3CumvtaTP9cg@mail.gmail.com>

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




view thread (8+ messages)  latest in thread

Message-ID: <20180424015058.yx7vtksqzjarzkrd@alvherre.pgsql>
Permalink:  ../20180424015058.yx7vtksqzjarzkrd@alvherre.pgsql/
Also on:    postgresql.org/message-id/20180424015058.yx7vtksqzjarzkrd@alvherre.pgsql

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: alvherre@alvh.no-ip.org, david.rowley@2ndquadrant.com
  Subject: Re: pgsql: Remove useless default clause in switch
  In-Reply-To: <20180424015058.yx7vtksqzjarzkrd@alvherre.pgsql>
  References: <CAKJS1f9vS7W0MDp-DJ0ixg3bMhJo0vdU-vzjZR3CumvtaTP9cg@mail.gmail.com> <20180424015058.yx7vtksqzjarzkrd@alvherre.pgsql>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox