On Fri, Jul 31, 2009 at 11:42:33AM +0200, Boszormenyi Zoltan wrote:
> made me look around more. Find the attached patch I came up with.
> Now my previous test code works and produces similar C code
> as without "-C INFORMIX". Can it be this simple?

Unfortunately it is not.

> Can you see anything wrong with this approach?

Yes, please look at the slightly changed test version that is attached to this 
email.

If you use e.g. int instead of MYTYPE, it works nicely, but not with MYTYPE.
Please see the comments in adjust_informix to see what this function is
supposed to do.

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: mes...@jabber.org
Go VfL Borussia! Go SF 49ers! Use Debian GNU/Linux! Use PostgreSQL!
/*
 * Test DECLARE ... SELECT ... INTO ...
 * with "string"
 * Does make ecpg segfault when run with -C INFORMIX
 */

#include <stdio.h>
#include <stdlib.h>

EXEC SQL BEGIN DECLARE SECTION;
EXEC SQL include test28.h;
EXEC SQL END DECLARE SECTION;

get_var(void)
{
        EXEC SQL BEGIN DECLARE SECTION;
        MYTYPE          myvar;
        EXEC SQL END DECLARE SECTION;

        EXEC SQL DECLARE mycur CURSOR FOR SELECT * INTO :myvar FROM a1 WHERE id 
= 1;
}

int main(int argc, char **argv) {
        EXEC SQL WHENEVER SQLWARNING SQLPRINT;
        EXEC SQL WHENEVER SQLERROR SQLPRINT;

        EXEC SQL connect to test;
        if (sqlca.sqlcode)
        {
                printf ("connect error = %ld\n", sqlca.sqlcode);
                exit (sqlca.sqlcode);
        }

        EXEC SQL CREATE TABLE a1 (id int, t text, d2 numeric, c text);

        EXEC SQL INSERT INTO a1 values(1, 'text1', 14.7, 'text2');

        get_var();
        EXEC SQL OPEN mycur;

        EXEC SQL WHENEVER NOT FOUND GOTO out;

        EXEC SQL FETCH FROM mycur;

        printf("c = '%s'\n", myvar.c);

out:
        EXEC SQL CLOSE mycur2;
        EXEC SQL CLOSE mycur;

        EXEC SQL DISCONNECT;

        return 0;
}
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to