Re: Use an enum for RELKIND_*?
От
Tom Lane
Тема
Re: Use an enum for RELKIND_*?
Дата
Msg-id
30043.1545191457@sss.pgh.pa.us
Ответ на
Re: Use an enum for RELKIND_*? (Kyotaro HORIGUCHI)
Список
Дерево обсуждения
Use an enum for RELKIND_*? Andres Freund <andres@anarazel.de>
Re: Use an enum for RELKIND_*? Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>
Re: Use an enum for RELKIND_*? Tom Lane <tgl@sss.pgh.pa.us>
Re: Use an enum for RELKIND_*? Andres Freund <andres@anarazel.de>
Re: Use an enum for RELKIND_*? Tom Lane <tgl@sss.pgh.pa.us>
Re: Use an enum for RELKIND_*? Andres Freund <andres@anarazel.de>
Re: Use an enum for RELKIND_*? Tom Lane <tgl@sss.pgh.pa.us>
Re: Use an enum for RELKIND_*? Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>
Re: Use an enum for RELKIND_*? Tom Lane <tgl@sss.pgh.pa.us>
Re: Use an enum for RELKIND_*? Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>
Re: Use an enum for RELKIND_*? Greg Stark <stark@mit.edu>
Re: Use an enum for RELKIND_*? Alvaro Herrera <alvherre@2ndquadrant.com>
Re: Use an enum for RELKIND_*? Greg Stark <stark@mit.edu>
Kyotaro HORIGUCHI writes: > At Tue, 18 Dec 2018 17:13:08 -0800, Andres Freund wrote in <20181219011308.mopzyvc73nwjzdb6@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
В списке pgsql-hackers по дате отправления