From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | 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:17:05 |
Message-ID: | 9587.1524532625@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
David Rowley <david(dot)rowley(at)2ndquadrant(dot)com> writes:
> On 24 April 2018 at 03:12, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org> wrote:
>> Remove useless default clause in switch
> 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.
Actually, there's an advantage to omitting the default for enum-based
switches, which is that many compilers will give you a compile-time
warning that you forgot a case. That beats an elog(ERROR) that you
might or might not hit in testing.
> There are other examples in that file with the switch
> (part_scheme->strategy), these are not using enums.
If it's not based on an enum then the compiler isn't going to understand
that you missed a value, so having the elog is better than having nothing.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Gierth | 2018-04-24 01:18:24 | Re: pgsql: Remove useless default clause in switch |
Previous Message | David Rowley | 2018-04-24 00:27:27 | Re: pgsql: Remove useless default clause in switch |