X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3514D52BF3 for ; Sun, 17 Jul 2005 05:41:30 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 35586-09 for ; Sun, 17 Jul 2005 08:41:24 +0000 (GMT) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.186]) by svr1.postgresql.org (Postfix) with ESMTP id 2ED7A52BE7 for ; Sun, 17 Jul 2005 05:41:23 -0300 (ADT) Received: from A2540.a.pppool.de [213.6.37.64] (helo=feivel) by mrelayeu.kundenserver.de with ESMTP (Nemesis), id 0MKwpI-1Du4iA22Ry-00070O; Sun, 17 Jul 2005 10:41:22 +0200 Received: by feivel (Postfix, from userid 1000) id 0E2F04AE52; Sat, 16 Jul 2005 23:54:10 +0200 (CEST) Date: Sat, 16 Jul 2005 23:54:09 +0200 From: Michael Meskes To: Dirk Jagdmann Cc: pgsql-interfaces@postgresql.org Subject: Re: ecpg and VARCHAR Message-ID: <20050716215409.GA13517@1> Mail-Followup-To: Dirk Jagdmann , pgsql-interfaces@postgresql.org References: <42D040E8.8060309@cubic.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <42D040E8.8060309@cubic.org> User-Agent: Mutt/1.5.9i X-Provags-ID: kundenserver.de abuse@kundenserver.de login:da5cff6069dd6897c77170232368d0ba X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.003 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200507/26 X-Sequence-Number: 5662 > I'd like to get some information on VARCHAR types with ecpg. If I > declare a VARCHAR without any size information I get a compilation error > from my gcc 3.4.4: > ... > Now I suppose this negative declaration should have initialized an empty > array and the generated sql code then allocates the space as needed? This is definitely a bug. The negative value is used internaly but should not make it into the generated code. > If I declared the VARCHAR with a size everything works fine. However I'd > like to know if the characters in the array contain a trailing 0 or if I > have to set this explicitely? No, they don't unless you set it to 0. > And then I'd like to know which is the preferred way to retrieve "text" > columns which contain arbitrary length texts with ecpg? Just use "char *ptr=NULL;" libecpg will then allocate the needed memory for you. You just have to free it later. But then, this should also work with varchar. :-) Michael -- Michael Meskes Email: Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org) ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes@jabber.org Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!