David Rowley <[email protected]> writes:
> On 24 April 2018 at 03:12, Alvaro Herrera <[email protected]> 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

Reply via email to