Обсуждение: ECPG fix for mixed case cursor names

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

ECPG fix for mixed case cursor names

От
Boszormenyi Zoltan
Дата:
Hi,

PostgreSQL allows in plain SQL to declare a cursor
e.g. in all lower case and fetch from is in all upper case.
We need to allow this from ECPG, too, but strictly when
the cursor name is not in a variable. Otherwise this code
below doesn't notice the cursor's double declaration
and complains using an undeclared cursor:

======================================
#include <stdio.h>

#include <sqlda.h>

int main(void)
{
    EXEC SQL BEGIN DECLARE SECTION;
    char    *connstr = "zozo@localhost:5555";
    EXEC SQL END DECLARE SECTION;
    sqlda_t    *sqlda;

    EXEC SQL CONNECT TO :connstr;

    EXEC SQL DECLARE mycur CURSOR FOR SELECT * FROM t1;

    EXEC SQL DECLARE MYCUR CURSOR FOR SELECT * FROM t1;

    EXEC SQL OPEN mYCur;

    EXEC SQL FETCH ALL FROM mYcUr INTO DESCRIPTOR sqlda;

    EXEC SQL CLOSE MyCuR;

    EXEC SQL DISCONNECT ALL;

    return 0;
}
======================================

Patch is attached.

Best regards,
Zoltán Böszörményi


Вложения

Re: ECPG fix for mixed case cursor names

От
Robert Haas
Дата:
2010/8/25 Boszormenyi Zoltan <zb@cybertec.at>:
> PostgreSQL allows in plain SQL to declare a cursor
> e.g. in all lower case and fetch from is in all upper case.
> We need to allow this from ECPG, too, but strictly when
> the cursor name is not in a variable. Otherwise this code
> below doesn't notice the cursor's double declaration
> and complains using an undeclared cursor:

It might be a good idea to add this to the open CommitFest so we don't
lose track of it.

https://commitfest.postgresql.org/action/commitfest_view/open

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise Postgres Company


Re: ECPG fix for mixed case cursor names

От
Michael Meskes
Дата:
On Wed, Aug 25, 2010 at 01:30:41PM +0200, Boszormenyi Zoltan wrote:
> PostgreSQL allows in plain SQL to declare a cursor
> e.g. in all lower case and fetch from is in all upper case.
> We need to allow this from ECPG, too, but strictly when
> the cursor name is not in a variable. Otherwise this code
> below doesn't notice the cursor's double declaration
> and complains using an undeclared cursor:
> ...

Applied. Thanks for spotting and fixing this.

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
Jabber: michael.meskes at googlemail dot com
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL