[ECPG] generates bad code on declare/open

Поиск
Список
Период
Сортировка
Искать
От
Tim Nelson
Тема
[ECPG] generates bad code on declare/open
Дата
Msg-id
63BD6AB4FBBED411B3E20004ACAE8B63014458@str_nt01.ecs-inc.com
Список
Дерево обсуждения
[ECPG] generates bad code on declare/open Tim Nelson <TNELSON@ECS-INC.com>
Re: [ECPG] generates bad code on declare/open Michael Meskes <meskes@postgresql.org>
How do I handle host variables passed in the where clause
of a declared cursor?  It seems "ecpg" 2.9 takes the declare/open
and puts the resulting code near the open.  This seems to be a bad
thing if the host variable is declared in a different block or function:

Consider...

func()
{  exec sql begin declare section;     int i;  exec sql end declare section;
  exec sql declare c1 cursor for select x from y where i = :i;
}
func2()
{  exec sql open c1;
}

...yields...
  /* exec sql begin declare section */


#line 3 "a.pgc"  int  i   ;
/* exec sql end declare section */
#line 4 "a.pgc"

  /* declare c1  cursor for select  x   from y where i  = ?   */
#line 6 "a.pgc"

}
func2()
{  { ECPGdo(__LINE__, NULL, "declare c1  cursor for select  x   from y where
i
= ?  ",  ECPGt_int,&(0~V7@0~V7@^P),1L,1L,sizeof(int),  ECPGt_NO_INDICATOR, NULL , 0L, 0L, 0L, ECPGt_EOIT, ECPGt_EORT);}
#line 10 "a.pgc"

}

Obviously the precompiler has no knowledge of the local host variable
in the other function.

Tim Nelson

В списке pgsql-interfaces по дате отправления
От: Tom Lane
Дата:
Сообщение: Re: libpq doing strange things
От: Benjamin.Feinstein@guardent.com
Дата:
FAQ