From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp> |
Cc: | andres(at)anarazel(dot)de, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Use an enum for RELKIND_*? |
Date: | 2018-12-19 03:50:57 |
Message-ID: | 30043.1545191457@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Kyotaro HORIGUCHI <horiguchi(dot)kyotaro(at)lab(dot)ntt(dot)co(dot)jp> writes:
> At Tue, 18 Dec 2018 17:13:08 -0800, Andres Freund <andres(at)anarazel(dot)de> wrote in <20181219011308(dot)mopzyvc73nwjzdb6(at)alap3(dot)anarazel(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Andres Freund | 2018-12-19 04:00:54 | Re: Use an enum for RELKIND_*? |
Previous Message | Kyotaro HORIGUCHI | 2018-12-19 02:19:34 | Re: Use an enum for RELKIND_*? |