Kyotaro HORIGUCHI <horiguchi.kyot...@lab.ntt.co.jp> writes: > At Tue, 18 Dec 2018 17:13:08 -0800, Andres Freund <and...@anarazel.de> wrote > in <20181219011308.mopzyvc73nwjz...@alap3.anarazel.de> >> Right now there's no easy way to use the compiler to ensure that all >> places that need to deal with all kinds of relkinds check a new >> relkind. I think we should make that easier by moving RELKIND_* to an >> enum, with the existing letters as the value.
> I think we cannot use enums having base-type, so it will work > unless we forget the cast within switch(). However, I don't think > it is not a reason not to do so. > > switch ((RelationRelkind) rel->rd_rel->relkind) Hm. This example doesn't seem very compelling. If we put a "default: elog(ERROR...)" into the switch, compilers will not warn us about omitted values. On the other hand, if we remove the default: then we lose robustness against corrupted relkind values coming from disk, which I think is going to be a net negative. Not to mention that we get no help at all unless we remember to add the cast to every such switch. So, while I understand Andres' desire to make this more bulletproof, I'm not quite sure how this proposal helps in practice. regards, tom lane