Peter Eisentraut <peter_e@gmx.net> writes:
> Tom Lane wrote:
>> It seems clear to me that this authorizes, but *does not require*,
>> the compiler to store an enum field in a byte or short instead of
>> an int when all the declared values will fit.
> FWIW, I never meant to suggest using enums tuple structures. I did,
> however, stumble over a case that appears to be handled similar to what
> I had in mind: see enum CoercionCodes in primnodes.h. Again, it's not
> really important, but it's interesting to see that there is precedent.
AFAIK, we don't store CoercionCodes in any system catalog columns.
But now that you mention it there is at least one place where we do
it like that: pg_depend.deptype is a "char" but its values are defined
by enum DependencyType. I have some recollection of doing it that way
because I was concerned that most places that cared about dependency
types should be switch statements that covered all the possible values
(which is pretty much the only benefit you get from doing it that way).
Having just gone over the typtype uses, there are only a couple of
places where we'd win from having that sort of compile-time check for
typtype.
regards, tom lane