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: 3BD6A5B4.BA37DFED@petig-baender.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
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
and
char *var=0;
reading one arbitrary length string into a malloced character
array

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)

Yours
Christof

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!)

Responses

Browse pgsql-interfaces by date

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