From: Michael Meskes <meskes@postgresql.org>
To: Dirk Jagdmann <doj@cubic.org>
Cc: pgsql-interfaces@postgresql.org
Subject: Re: ecpg and VARCHAR
Date: Sat, 16 Jul 2005 23:54:09 +0200
Message-ID: <20050716215409.GA13517@1> (raw)
In-Reply-To: <42D040E8.8060309@cubic.org>
References: <42D040E8.8060309@cubic.org>
> 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!
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 using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: meskes@postgresql.org, doj@cubic.org
Subject: Re: ecpg and VARCHAR
In-Reply-To: <20050716215409.GA13517@1>
* 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