ecpg bug with SQL TYPE xxxPtr is xxx REFERENCE?

Поиск
Список
Период
Сортировка
От lkindness@csl.co.uk (Lee Kindness)
Тема ecpg bug with SQL TYPE xxxPtr is xxx REFERENCE?
Дата
Msg-id 3fb2003d.0108080807.7ec5e135@posting.google.com
обсуждение исходный текст
Ответы Re: ecpg bug with SQL TYPE xxxPtr is xxx REFERENCE?
Список pgsql-interfaces
Hi,

I believe ecpg is incorrectly handling the placement of results into a
pointer to a host structure, consider the following function:

GeoContractorTabPtr sel_geo_contractor_rec(char *project_id)
{  EXEC SQL BEGIN DECLARE SECTION; GeoContractorTabPtr ptr; char *id; EXEC SQL END DECLARE SECTION;
 id = project_id;
 tab_geo_contractor = calloc(1, sizeof(GeoContractorTabStr)); ptr = tab_geo_contractor;
 EXEC SQL SELECT *   INTO :ptr   FROM geo_contractor   WHERE project_id = :id;
 return( tab_geo_contractor );
}

and the following type definitions:

/* Description of table geo_contractor from database  */
EXEC SQL TYPE GeoContractorTabStr IS STRUCT { char    project_id[9]; char    contractor[53];
};
EXEC SQL TYPE GeoContractorTabPtr IS GeoContractorTabStr REFERENCE;

The following code is output by ecpg:

GeoContractorTabPtr sel_geo_contractor_rec(char *project_id)
{  /* exec sql begin declare section */  GeoContractorTabPtr  ptr   ;  char * id   ; /* exec sql end declare section
*/
 id = project_id; tab_geo_contractor = calloc(1, sizeof(GeoContractorTabStr)); ptr = tab_geo_contractor;

{ ECPGdo(__LINE__, NULL, "select  *  from geo_contractor  where
project_id  = ?     ",ECPGt_char,&(id),0L,1L,1*sizeof(char), ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT,
ECPGt_char,(ptr.project_id),9L,1L,9*sizeof(char),ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L,
ECPGt_char,(ptr.contractor),53L,1L,53*sizeof(char),ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EORT);
 
 return( tab_geo_contractor );
}

Specifically ptr.project_id should be ptr->project_id and likewise for
contractor. Am I correct in this?

Thanks, Lee Kindness.


В списке pgsql-interfaces по дате отправления:

Предыдущее
От: iafmgc@unileon.es
Дата:
Сообщение: RE: pg_hba.conf and password files
Следующее
От: Michael Meskes
Дата:
Сообщение: Argh (was about an ECPG bug)