Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id CA48A1337999 for ; Tue, 2 Nov 2010 18:21:02 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 83880-03; Tue, 2 Nov 2010 21:20:55 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from exprod7og114.obsmtp.com (exprod7og114.obsmtp.com [64.18.2.215]) by mail.postgresql.org (Postfix) with SMTP id D0373133798F; Tue, 2 Nov 2010 18:20:54 -0300 (ADT) Received: from source ([209.85.213.42]) by exprod7ob114.postini.com ([64.18.6.12]) with SMTP ID DSNKTNCAtqVLtSyvDnJeVcT7HyPii3dQRLU2@postini.com; Tue, 02 Nov 2010 14:20:55 PDT Received: by mail-yw0-f42.google.com with SMTP id 9so4363592ywf.1 for ; Tue, 02 Nov 2010 14:20:53 -0700 (PDT) Received: by 10.42.22.133 with SMTP id o5mr12828867icb.268.1288732853247; Tue, 02 Nov 2010 14:20:53 -0700 (PDT) Received: from [192.168.2.36] (va-76-4-65-131.sta.embarqhsd.net [76.4.65.131]) by mx.google.com with ESMTPS id w30sm3113111vcr.16.2010.11.02.14.20.51 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 02 Nov 2010 14:20:52 -0700 (PDT) Cc: Michael Meskes , Zoltan Boszormenyi , PostgreSQL Bugs Message-Id: <66079D10-FE03-487F-B79D-9649F5C67048@enterprisedb.com> From: Korry Douglas To: Heikki Linnakangas In-Reply-To: <4CD067D0.6000900@enterprisedb.com> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v936) Subject: Re: ecpg preprocessor regression in 9.0 Date: Tue, 2 Nov 2010 17:20:49 -0400 References: <4CCEC145.3020409@enterprisedb.com> <4CCEC4D8.2090809@enterprisedb.com> <20101102173913.GA32303@hyperion.credativ.de> <4CD067D0.6000900@enterprisedb.com> X-Mailer: Apple Mail (2.936) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-4.2 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3 X-Spam-Level: X-Archive-Number: 201011/21 X-Sequence-Number: 28601 >>> 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