Skip site navigation (1) Skip section navigation (2)

ECPG: Automatic Storage allocation for NULL-pointing output variables

From: Christof Petig <christof(at)petig-baender(dot)de>
To: Interfaces <pgsql-interfaces(at)postgresql(dot)org>
Cc: Michael Meskes <meskes(at)postgresql(dot)org>
Subject: ECPG: Automatic Storage allocation for NULL-pointing output variables
Date: 2001-10-24 11:27:48
Message-ID: (view raw or whole thread)
Lists: pgsql-interfaces
Hi there,

I'm looking for an alternative to statically sized character arrays
within ECPG.

E.g. exec sql select relname into :VAR from pg_classes;

It should (!) be possible to obtain this by using pointers which are
initialized to NULL.

It is possible for
    integer *var=0;
        reading an arbitrary number of integers into a malloced array
    char *var=0;
        reading one arbitrary length string into a malloced character

Works perfectly.

But ecpg does not accept
    char **var=0;

Is there any way to specify arbitrary strings of any length ?

The code (execute.c:435) has also support for varchar - but how to
declare such a variable length varchar?

And the code (execute.c:432) multiplies the number of tuples with the
longest string. But how to use this code in real life?

Looks like dead code to me (hopefully I'm wrong)


PS: I'm willing to implement char**
(allocate tuples*sizeof(char*) + sum(length(tuple[n])+1) bytes,
 fill the array with pointers,
 fill the space behind the array with the actual data.
 This means just one free get's it all.
 But this code cannot be portable!)


pgsql-interfaces by date

Next:From: D'Arcy J.M. CainDate: 2001-10-24 12:04:44
Subject: Re: Python interface and Money?
Previous:From: Bruce MomjianDate: 2001-10-23 16:45:50
Subject: Re: ECPG - connection name in "EXEC SQL AT ... " statement

Privacy Policy | About PostgreSQL
Copyright © 1996-2015 The PostgreSQL Global Development Group