pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Korry Douglas <korry.douglas@enterprisedb.com>
To: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
Cc: Michael Meskes <meskes@postgresql.org>
Cc: Zoltan Boszormenyi <zb@cybertec.at>
Cc: PostgreSQL Bugs <pgsql-bugs@postgresql.org>
Subject: Re: ecpg preprocessor regression in 9.0
Date: Tue, 2 Nov 2010 17:20:49 -0400
Message-ID: <66079D10-FE03-487F-B79D-9649F5C67048@enterprisedb.com> (raw)
In-Reply-To: <4CD067D0.6000900@enterprisedb.com>
References: <4CCEC145.3020409@enterprisedb.com>
	<4CCEC4D8.2090809@enterprisedb.com>
	<20101102173913.GA32303@hyperion.credativ.de>
	<4CD067D0.6000900@enterprisedb.com>

>>> On closer look, it's quite obvious: the code added to
>>> ECPGdump_a_type thinks that ECPGt_const is a variable type, and
>>> tries to look up the variable. The straightforward fix is this:
>>> ...
>>> But I wonder if there is a better way to identify variable-kind of
>>> ECPGttypes than list the ones that are not. There's some special
>>> ECPGttypes still missing from the above if-test, like
>>> ECPGt_NO_INDICATOR, but I'm not sure if they can ever be passed to
>>> ECPGdump_a_type. Seems a bit fragile anyway.
>>
>> I agree. How about adding a macro definition explicitely checking  
>> for the real
>> variable types?
>
> You'd still have to list them all in the macro, but it would  
> definitely be better. The list would then be closer to the enums, in  
> the same header file, making it easier to remember to keep it up-to- 
> date. (Korry's suggestion of making it a function instead of a macro  
> would not have that advantage).


Sure it would... use a switch statement that explicitly handles each  
type and include a default case that throws an error (or assertion).   
Of course, you have to run into the code to find out that you forgot  
to maintain the classification function. A good C compiler will even  
spot the problem if you forget to handle one or more enum values in  
the switch statement. A macro offers no assurances at all.


			-- Korry



view thread (7+ messages)  latest in thread

Message-ID: <66079D10-FE03-487F-B79D-9649F5C67048@enterprisedb.com>
Permalink:  ../66079D10-FE03-487F-B79D-9649F5C67048@enterprisedb.com/
Also on:    postgresql.org/message-id/66079D10-FE03-487F-B79D-9649F5C67048@enterprisedb.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: korry.douglas@enterprisedb.com, heikki.linnakangas@enterprisedb.com, meskes@postgresql.org, zb@cybertec.at
  Subject: Re: ecpg preprocessor regression in 9.0
  In-Reply-To: <66079D10-FE03-487F-B79D-9649F5C67048@enterprisedb.com>
  References: <4CCEC145.3020409@enterprisedb.com> <4CCEC4D8.2090809@enterprisedb.com> <20101102173913.GA32303@hyperion.credativ.de> <4CD067D0.6000900@enterprisedb.com> <66079D10-FE03-487F-B79D-9649F5C67048@enterprisedb.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox