Skip to content

Commit e01c6ce

Browse files
author
Michael Meskes
committed
Give a more precise error message if a variable is re-used as cursor name in ecpg.
1 parent d174a4a commit e01c6ce

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/interfaces/ecpg/preproc/ecpg.addons

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.addons,v 1.18 2010/03/23 22:12:06 petere Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.addons,v 1.19 2010/03/31 08:45:18 meskes Exp $ */
22
ECPG: stmtClosePortalStmt block
33
{
44
if (INFORMIX_MODE)
@@ -306,7 +306,12 @@ ECPG: DeclareCursorStmtDECLAREcursor_namecursor_optionsCURSORopt_holdFORSelectSt
306306
for (ptr = cur; ptr != NULL; ptr = ptr->next)
307307
{
308308
if (strcmp($2, ptr->name) == 0)
309-
mmerror(PARSE_ERROR, ET_ERROR, "cursor \"%s\" is already defined", $2);
309+
{
310+
if ($2[0] == ':')
311+
mmerror(PARSE_ERROR, ET_ERROR, "using variable \"%s\" in different declare statements is not supported", $2+1);
312+
else
313+
mmerror(PARSE_ERROR, ET_ERROR, "cursor \"%s\" is already defined", $2);
314+
}
310315
}
311316

312317
this = (struct cursor *) mm_alloc(sizeof(struct cursor));

src/interfaces/ecpg/preproc/ecpg.trailer

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.trailer,v 1.23 2010/03/21 11:56:45 meskes Exp $ */
1+
/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.trailer,v 1.24 2010/03/31 08:45:18 meskes Exp $ */
22

33
statements: /*EMPTY*/
44
| statements statement
@@ -296,8 +296,13 @@ ECPGCursorStmt: DECLARE cursor_name cursor_options CURSOR opt_hold FOR prepared
296296
for (ptr = cur; ptr != NULL; ptr = ptr->next)
297297
{
298298
if (strcmp($2, ptr->name) == 0)
299+
{
299300
/* re-definition is a bug */
300-
mmerror(PARSE_ERROR, ET_ERROR, "cursor \"%s\" is already defined", $2);
301+
if ($2[0] == ':')
302+
mmerror(PARSE_ERROR, ET_ERROR, "using variable \"%s\" in different declare statements is not supported", $2+1);
303+
else
304+
mmerror(PARSE_ERROR, ET_ERROR, "cursor \"%s\" is already defined", $2);
305+
}
301306
}
302307

303308
this = (struct cursor *) mm_alloc(sizeof(struct cursor));

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy