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

Re: ECPG: Automatic Storage allocation for NULL-pointing

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: Re: ECPG: Automatic Storage allocation for NULL-pointing
Date: 2001-10-30 09:46:03
Message-ID: 3BDE76DB.90039F22@petig-baender.de (view raw or flat)
Thread:
Lists: 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)
  which is pretty useless for an output variable but might be ok for an input
  variable if the offset (sizeof char) would be right (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)



In response to

Responses

pgsql-interfaces by date

Next:From: Christof PetigDate: 2001-10-30 10:02:28
Subject: Re: ECPG - connection name in "EXEC SQL AT ... " statement
Previous:From: DI HasenöhrlDate: 2001-10-30 08:42:20
Subject: Re: DAO VB ODBC "read only problems

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