From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr> |
Cc: | Andres Freund <andres(at)anarazel(dot)de>, Robert Haas <robertmhaas(at)gmail(dot)com>, Thom Brown <thom(at)linux(dot)com>, Abhijit Menon-Sen <ams(at)2ndquadrant(dot)com>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Haribabu Kommi <kommi(dot)haribabu(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: [BUGS] Breakage with VACUUM ANALYSE + partitions |
Date: | 2016-05-04 17:31:18 |
Message-ID: | 13345.1462383078@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs pgsql-hackers |
Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr> writes:
> I understood the point and I do not see real disadvantages. The C standard
> really says that an enum is an int, and compilers just do that.
No, it doesn't say that, and compilers don't just do that. A compiler
is specifically allowed to store an enum in char or short if the enum's
declared values would all fit into that width. (Admittedly, if you're
choosing the values as powers of 2, an OR of them would still fit; but
if you think "oh, an enum is just an int", you will get burned.)
More to the point, once you allow OR'd values then none of the practical
benefits of an enum still hold good. The typical things that I rely on
in an enum that you don't get from a collection of #define's are:
* compiler warnings if you forget some members of the enum in a switch
* debugger ability to print variables symbolically
Those benefits both go up in smoke as soon as you allow OR'd values.
At that point you might as well use the #defines rather than playing
language lawyer about whether what you're doing meets the letter of
the spec. I note that C99 specifically mentions this as something
a compiler might warn about:
-- A value is given to an object of an enumeration type
other than by assignment of an enumeration constant
that is a member of that type, or an enumeration
variable that has the same type, or the value of a
function that returns the same enumeration type
(6.7.2.2).
which certainly looks like they don't consider
"enumvar = ENUMVAL1 | ENUMVAL2" to be strictly kosher.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Stephen Frost | 2016-05-04 17:44:38 | Re: [BUGS] Breakage with VACUUM ANALYSE + partitions |
Previous Message | Fabien COELHO | 2016-05-04 16:29:08 | Re: [BUGS] Breakage with VACUUM ANALYSE + partitions |
From | Date | Subject | |
---|---|---|---|
Next Message | Stephen Frost | 2016-05-04 17:44:38 | Re: [BUGS] Breakage with VACUUM ANALYSE + partitions |
Previous Message | Tom Lane | 2016-05-04 17:15:08 | Re: Naming of new tsvector functions |