pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: David Rowley <david.rowley@2ndquadrant.com>
Cc: Alvaro Herrera <alvherre@alvh.no-ip.org>
Cc: pgsql-committers@lists.postgresql.org
Subject: Re: pgsql: Remove useless default clause in switch
Date: Tue, 24 Apr 2018 10:20:42 +0900
Message-ID: <20180424012042.GD1570@paquier.xyz> (raw)
In-Reply-To: <CAKJS1f9vS7W0MDp-DJ0ixg3bMhJo0vdU-vzjZR3CumvtaTP9cg@mail.gmail.com>
References: <E1fAd8s-0003wZ-AV@gemulon.postgresql.org>
	<CAKJS1f9vS7W0MDp-DJ0ixg3bMhJo0vdU-vzjZR3CumvtaTP9cg@mail.gmail.com>

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.

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

Attachments:

partprune-useless-default.patch (text/x-diff, 436B) download diff --git a/src/backend/partitioning/partprune.c b/src/backend/partitioning/partprune.c index f8844ef2eb..cbbb4c1827 100644 --- a/src/backend/partitioning/partprune.c +++ b/src/backend/partitioning/partprune.c @@ -2950,10 +2950,6 @@ perform_pruning_combine_step(PartitionPruneContext *context, } } break; - - default: - elog(ERROR, "invalid pruning combine op: %d", - (int) cstep->combineOp); } return result;
signature.asc (application/pgp-signature, 832B) download

view thread (8+ messages)  latest in thread

Message-ID: <20180424012042.GD1570@paquier.xyz>
Permalink:  ../20180424012042.GD1570@paquier.xyz/
Also on:    postgresql.org/message-id/20180424012042.GD1570@paquier.xyz

 ·  · 

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: michael@paquier.xyz, david.rowley@2ndquadrant.com, alvherre@alvh.no-ip.org
  Subject: Re: pgsql: Remove useless default clause in switch
  In-Reply-To: <20180424012042.GD1570@paquier.xyz>
  References: <E1fAd8s-0003wZ-AV@gemulon.postgresql.org> <CAKJS1f9vS7W0MDp-DJ0ixg3bMhJo0vdU-vzjZR3CumvtaTP9cg@mail.gmail.com> <20180424012042.GD1570@paquier.xyz>

* 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