Re: WIP: guc enums - Mailing list pgsql-patches

From Magnus Hagander
Subject Re: WIP: guc enums
Date
Msg-id 20080305152027.GS5559@svr2.hagander.net
Whole thread Raw
In response to Re: WIP: guc enums  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-patches
On Wed, Mar 05, 2008 at 08:18:19AM -0500, Tom Lane wrote:
> "Heikki Linnakangas" <heikki@enterprisedb.com> writes:
> > Tom Lane wrote:
> >> What I'd suggest is declaring the actual variable as int.  You can still
> >> use an enum typedef to declare the values, and just avert your eyes
> >> when you have to cast the enum to int or vice versa.  (This is legal per
> >> C spec, so you won't introduce any portability issues when you do it.)
>
> > That's pretty much the same as int variable and #defined constants. You
> > lose compiler checks, like assigning from one enum type to another, and
> > the "enumeration value �FOOBAR� not handled in switch" warning.
>
> Well, you can at least get the latter if you cast explicitly:
>
>     switch ((MyEnum) myvariable) ...
>
> We do this in several places already where the underlying variable isn't
> declared as the enum for one reason or another.  Also, local variables
> can be declared as the enum type to get a little more safety.

Looking for the two variables I've converted so far, there appears to be
zero places to make this change. They are only used in == and <= tests,
never in switches. Or should I add casts for those as well?

(I'm sure there can be other variables that are used in enums when I get
further down that list)

If we're good with that method, I'll proceed using that one. Any other
things people noticed with the patch that I should take into consideration
when I start my cleanup pass over the code?

//Magnus

pgsql-patches by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: WIP: guc enums
Next
From: Bruce Momjian
Date:
Subject: Re: [BUGS] BUG #3975: tsearch2 index should not bomb out of 1Mb limit