Re: ECPG: Automatic Storage allocation for NULL-pointing - Mailing list pgsql-interfaces

From Christof Petig
Subject Re: ECPG: Automatic Storage allocation for NULL-pointing
Date
Msg-id 3BDE76DB.90039F22@petig-baender.de
Whole thread Raw
In response to ECPG: Automatic Storage allocation for NULL-pointing output variables  (Christof Petig <christof@petig-baender.de>)
Responses Re: ECPG: Automatic Storage allocation for NULL-pointing  (Michael Meskes <meskes@postgresql.org>)
List pgsql-interfaces
Christof Petig wrote:

> > > > exec sql type str is varchar[8];
> > > > str *var=NULL;
> > >
> > > Shudder. There should be a decent syntax to specify this. If anyone ever
> > > needs this functionality!!!

I found the actual way to get this :

- it is possible to create a pointer to a varchar, simply use the
braindead (to me) syntax:
   varchar type[][maxlen]=0;      or   varchar type[0][maxlen]=0;

- ecpg and the C compiler do not agree on the meaning of
  char *foo[80];
 for the compiler it is an array of 80 char*s for ecpg it's obviously equivalent to char foo[80][0]; (simply try it)
whichis pretty useless for an output variable but might be ok for an input variable if the offset (sizeof char) would
beright (sizeof char*).
 

- the interesting syntax
   char (*foo)[80];   (pointer to an array of char[80])
 is not possible in ecpg, but seems to be the one supported by the lib.


To sum it up: variable declaration and variable initialization are some of the
weakest points in ecpg.

Christof (implementing char **)

PS: casts do not work when initializing variables ( e.g.    int VAR = (int) 1.5; ->
syntax error)




pgsql-interfaces by date:

Previous
From: DI Hasenöhrl
Date:
Subject: Re: DAO VB ODBC "read only problems
Next
From: Christof Petig
Date:
Subject: Re: ECPG - connection name in "EXEC SQL AT ... " statement