Re: ECPG support for struct in INTO list

From: Michael Meskes <meskes(at)postgresql(dot)org>
To: Boszormenyi Zoltan <zb(at)cybertec(dot)at>
Cc: Michael Meskes <meskes(at)postgresql(dot)org>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Hans-Juergen Schoenig <hs(at)cybertec(dot)at>
Subject: Re: ECPG support for struct in INTO list
Date: 2009-08-07 08:01:07
Message-ID: 20090807080107.GA2458@feivel.credativ.lan
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Aug 05, 2009 at 04:22:53PM +0200, Boszormenyi Zoltan wrote:
> If you meant like this below, then ECPG segfaults on this too:

Right, because arrays as as well unimplemented as are structs. I meant
something like this;

int *
get_var(void)
{
EXEC SQL BEGIN DECLARE SECTION;
static int myvar;
EXEC SQL END DECLARE SECTION;

EXEC SQL DECLARE mycur CURSOR FOR SELECT id INTO :myvar FROM a1 WHERE id = 1;
return (&myvar);
}

> Attached is my modified test28.pgc. Compiling it
> *without* -C INFORMIX makes it unusable, the variable
> or the address where the data should be fetched into
> doesn't even gets emitted in neither the DECLARE/OPEN
> nor the FETCH callsites. I think this code should be valid
> even in non-Informix-compatible mode.

I don't think i buy into this. The variable is out of scope at the time open is
called. Why do you think this should work?

> > ... Just look at
> > test/compat_informix/test_informix.pgc for a real and working example.
> >
>
> The example there is the other way around.
> The variable, the DECLARE and FETCH commands
> are in the outer main() function, and it calls a function called
> openit() where the OPEN command is emitted, so that
> example doesn't help here too much.

Eh, why not? We're talking about a bug/missing feature in the precompiler
itself. And the precompiler doesn't see this difference. I just pointed you to
one working example. Anyway I attached a modified test28.pgc that should work
in compatibility mode.

Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
ICQ: 179140304, AIM/Yahoo/Skype: michaelmeskes, Jabber: meskes(at)jabber(dot)org
Go VfL Borussia! Go SF 49ers! Use Debian GNU/Linux! Use PostgreSQL!

Attachment Content-Type Size
test28,pgc text/plain 1.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Stark 2009-08-07 08:23:06 Re: [Pg-migrator-general] Composite types break pg_migrated tables
Previous Message Magnus Hagander 2009-08-07 07:31:23 Re: include/commands/version.h is not used