Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id D61EF633324 for ; Wed, 22 Apr 2009 10:04:51 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 56621-07 for ; Wed, 22 Apr 2009 10:04:37 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sd.tpf.co.jp (sd.tpf.co.jp [210.161.239.34]) by mail.postgresql.org (Postfix) with SMTP id EC9B3632ECD for ; Wed, 22 Apr 2009 10:04:44 -0300 (ADT) Received: (qmail 13702 invoked by uid 512); 22 Apr 2009 13:04:23 -0000 X-Authentication: inoue was authenticated by sd.tpf.co.jp at 22 Apr 2009 13:04:23 -0000 Received: from unknown (HELO ?192.168.11.3?) (219.61.40.6) by sd.tpf.co.jp with SMTP; 22 Apr 2009 13:04:23 -0000 Message-ID: <49EF15D5.7060307@tpf.co.jp> Date: Wed, 22 Apr 2009 22:04:21 +0900 From: Hiroshi Inoue User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) MIME-Version: 1.0 To: Alex Goncharov CC: pgsql-odbc@postgresql.org Subject: Re: A platform-specific defect in the ODBC driver References: In-Reply-To: Content-Type: text/plain; charset=ISO-2022-JP Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.67 tagged_above=0 required=5 tests=AWL=-0.455, DNS_FROM_RFC_BOGUSMX=2.125 X-Spam-Level: * X-Archive-Number: 200904/21 X-Sequence-Number: 9840 Hi Alex, Alex Goncharov wrote: > Hello Hiroshi, > > I hope I am addressing this message correctly. > > Consider this code in `statement.c': > > ------------------------------------------------------------ > static void SC_init_parse_method(StatementClass *self) > { > if (self->multi_statement <= 0 && ...) > SC_set_parse_tricky(self); > } > > StatementClass * > SC_Constructor(ConnectionClass *conn) > { > rv->multi_statement = -1; /* unknown */ > } > ------------------------------------------------------------ > > There is obviously an assumption here that `multi_statement' can, > under certain circumstances, be negative. And, indeed, this is what > `statement.h' says about it: > > ------------------------------------------------------------ > struct StatementClass_ > { > char multi_statement; /* -1:unknown 0:single 1:multi */ > }; > > ------------------------------------------------------------ > > so, `multi_statement' is a three-valued entity, with -1 being one of > the possible values. > > But what if `char' is an unsigned type? Then assigning -1 to > `multi_statement' will result in it being 255, and comparisons like > `<= 0' won't make sense. > > Can `char' be unsigned? Yes, it can, per paragraph 15 in the ISO > C, Section 6.2.5: > > 15 The three types char, signed char, and unsigned char are > collectively called the character types. The implementation > shall define char to have the same range, representation, and > behavior as either signed char or unsigned char.35) > > Various compilers on AIX consider `char' to be unsigned, and the code > compiled there (with gcc), will fail miserably on some operations. I see. > A possible and probably the best resolution is to give > `multi_statement' and similar "to-be-three-valued" variables a good > "indicator" type, which can allow all the expected values, -1, 0 and 1 > and legit comparisons between them. > > The enclosed patch does it and resolves the failures on AIX > completely. > > Please consider including this or a similar fix into the official > distribution of the ODBC driver. OK I would take care of it in 8.4.0100 release. regards, Hiroshi Inoue