Обсуждение: ecpg mapping struct members for indicators incorrectly?

Поиск
Список
Период
Сортировка

ecpg mapping struct members for indicators incorrectly?

От
Shelby Cain
Дата:
I'm coming from a Pro*C background so I'm not entirely
certain whether what I am attempting is simply not
allowed in ecpg or not.

ecpg --version
ecpg (PostgreSQL 7.4.1) 3.1.0

showbug.pgc
------------------------------------------
#define HOSTSIZE 100

exec sql begin declare section;

typedef struct _my_host_t {
  char field1[HOSTSIZE][20];
  int field2[HOSTSIZE];
} _my_host_ary_t;

typedef struct _my_host_ind_t {
  int field1_ind[HOSTSIZE];
  int field2_ind[HOSTSIZE];
} _my_host_ind_ary_t;

exec sql end declare section;

exec sql declare my_cur cursor for select field1,
field2 from sometable;

int main()
{
  exec sql begin declare section;

  _my_host_ary_t *mydata;
  _my_host_ind_ary_t *myind;
  int fetchsize;

  exec sql end declare section;

  fetchsize = HOSTSIZE;

  exec sql fetch :fetchsize from my_cur into :mydata
INDICATOR :myind;

}
------------------------------------------

After running ecpg -o showbug.c showbug.pgc the
section of interest in the generated .c file is:

showbug.c
------------------------------------------
/* Processed by ecpg (3.1.0) */

[...]

int main()
{
  /* exec sql begin declare section */

[...]

  { ECPGdo(__LINE__, 0, 1, NULL, "fetch  ? from
my_cur",

ECPGt_int,&(vArySize),(long)1,(long)1,sizeof(int),
        ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_EOIT,

ECPGt_char,(mydata->field1),(long)20,(long)HOSTSIZE,20*sizeof(char),

ECPGt_int,(mydata->field1_ind),(long)1,(long)HOSTSIZE,sizeof(int),

ECPGt_int,(mydata->field2),(long)1,(long)HOSTSIZE,sizeof(int),


ECPGt_int,(mydata->field2_ind),(long)1,(long)HOSTSIZE,sizeof(int),
ECPGt_EORT);}

[...]

}

You can see that ecpg incorrectly mapped the indicator
fields field1_ind and field2_ind to the mydata struct
instead of myind which will cause a compile error.

Regards,

Shelby Cain



__________________________________
Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.
http://antispam.yahoo.com/tools

Re: ecpg mapping struct members for indicators incorrectly?

От
Michael Meskes
Дата:
On Thu, Feb 19, 2004 at 11:57:33AM -0800, Shelby Cain wrote:
> I'm coming from a Pro*C background so I'm not entirely
> certain whether what I am attempting is simply not
> allowed in ecpg or not.

Well it should be. :-)

Thanks for reporting the bug. I just committed a fix to HEAD and
REL7_4_STABLE so it should be in 7.4.2.

Michael

--
Michael Meskes
Email: Michael at Fam-Meskes dot De
ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes@jabber.org
Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!

Re: ecpg mapping struct members for indicators incorrectly?

От
Shelby Cain
Дата:
--- Michael Meskes <meskes@postgresql.org> wrote:
> On Thu, Feb 19, 2004 at 11:57:33AM -0800, Shelby
> Cain wrote:
> > I'm coming from a Pro*C background so I'm not
> entirely
> > certain whether what I am attempting is simply not
> > allowed in ecpg or not.
>
> Well it should be. :-)
>
> Thanks for reporting the bug. I just committed a fix
> to HEAD and
> REL7_4_STABLE so it should be in 7.4.2.
>

No problem.  Thanks for the quick response.

__________________________________
Do you Yahoo!?
Get better spam protection with Yahoo! Mail.
http://antispam.yahoo.com/tools