Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id A7ADF4766CD; Thu, 4 Jul 2002 10:29:47 -0400 (EDT) Mailbox-Line: From meskes@postgresql.org Thu Jul 4 10:29:47 2002 Received: from www.credativ.de (cdt1.tz-juelich.de [195.37.52.66]) by postgresql.org (Postfix) with ESMTP id 93FEF476610; Thu, 4 Jul 2002 10:15:24 -0400 (EDT) Received: from feivel.credativ.de (feivel.credativ.de [172.26.14.7]) by www.credativ.de (Postfix) with ESMTP id CD378D691A; Thu, 4 Jul 2002 16:21:11 +0200 (CEST) Received: by feivel.credativ.de (Postfix, from userid 1000) id B11B7A6052; Thu, 4 Jul 2002 16:21:01 +0200 (CEST) Date: Thu, 4 Jul 2002 16:21:01 +0200 From: Michael Meskes To: Raymond Fung Cc: pgsql-admin , pgsql-hackers , lockhart@fourpalms.org Subject: Re: [HACKERS] ecpg problem : pre-processor translated long constant to char Message-ID: <20020704142101.GA32633@feivel.credativ.de> Mail-Followup-To: Raymond Fung , pgsql-admin , pgsql-hackers , lockhart@fourpalms.org References: <3D23AC21.FC1D6579@iohk.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3D23AC21.FC1D6579@iohk.com> User-Agent: Mutt/1.3.28i X-Spam-Status: No, hits=-5.3 required=5.0 tests=IN_REP_TO,X_NOT_PRESENT version=2.30 X-Spam-Level: X-Archive-Number: 200207/88 X-Sequence-Number: 4774 On Thu, Jul 04, 2002 at 10:00:01AM +0800, Raymond Fung wrote: > Dear all, > ... > It has translated the 4 bytes constant (0x87654321) into a one byte > char constant (within the single quotes) during pre-processing. Seems > this happens only when the high bit of the constant is set (i.e. it > won't add the quotes if the constant is 0x12345678). Yes, this is a bug. But look here: mm=# create table test (i int8); CREATE mm=# insert into test values (x'80000000'); ERROR: Bad hexadecimal integer input '80000000' mm=# insert into test values (1234567890123); INSERT 22762 1 The reason is that both the backend parser and the ecpg parser use strtol to parse the hex constant. And strtol does not like anything > 0x80000000. > Also, I noticed that the line number reported during the preprocessing > error output is incorrect : it is '1' less than the actual line number > in the source file. As shown, I am using version 2.8.0 of ecpg. Is my > version being too old to be buggy ? Any suggestion to bypass the > translation problem ? I heard about the off-by-one problem sometimes, but I've yet to find the time to look for the reason. A collegue is bugging me all the time. :-) Michael -- Michael Meskes Michael@Fam-Meskes.De Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!