aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meskes <meskes@postgresql.org>2010-03-31 08:45:18 +0000
committerMichael Meskes <meskes@postgresql.org>2010-03-31 08:45:18 +0000
commite01c6ce712d3db0ae1f2205d9dae1168f1da1f5d (patch)
tree0ead059ff069399a5d08621be17d0cef84bb3145
parentd174a4adbb7423ee5ff30aa98043db4521ffd1be (diff)
downloadpostgresql-e01c6ce712d3db0ae1f2205d9dae1168f1da1f5d.tar.gz
postgresql-e01c6ce712d3db0ae1f2205d9dae1168f1da1f5d.zip
Give a more precise error message if a variable is re-used as cursor name in ecpg.
-rw-r--r--src/interfaces/ecpg/preproc/ecpg.addons9
-rw-r--r--src/interfaces/ecpg/preproc/ecpg.trailer9
2 files changed, 14 insertions, 4 deletions
diff --git a/src/interfaces/ecpg/preproc/ecpg.addons b/src/interfaces/ecpg/preproc/ecpg.addons
index 818ef540c2c..a6760d4b913 100644
--- a/src/interfaces/ecpg/preproc/ecpg.addons
+++ b/src/interfaces/ecpg/preproc/ecpg.addons
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.addons,v 1.18 2010/03/23 22:12:06 petere Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.addons,v 1.19 2010/03/31 08:45:18 meskes Exp $ */
ECPG: stmtClosePortalStmt block
{
if (INFORMIX_MODE)
@@ -306,7 +306,12 @@ ECPG: DeclareCursorStmtDECLAREcursor_namecursor_optionsCURSORopt_holdFORSelectSt
for (ptr = cur; ptr != NULL; ptr = ptr->next)
{
if (strcmp($2, ptr->name) == 0)
- mmerror(PARSE_ERROR, ET_ERROR, "cursor \"%s\" is already defined", $2);
+ {
+ if ($2[0] == ':')
+ mmerror(PARSE_ERROR, ET_ERROR, "using variable \"%s\" in different declare statements is not supported", $2+1);
+ else
+ mmerror(PARSE_ERROR, ET_ERROR, "cursor \"%s\" is already defined", $2);
+ }
}
this = (struct cursor *) mm_alloc(sizeof(struct cursor));
diff --git a/src/interfaces/ecpg/preproc/ecpg.trailer b/src/interfaces/ecpg/preproc/ecpg.trailer
index 436c4fda4bd..d5e16afab60 100644
--- a/src/interfaces/ecpg/preproc/ecpg.trailer
+++ b/src/interfaces/ecpg/preproc/ecpg.trailer
@@ -1,4 +1,4 @@
-/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.trailer,v 1.23 2010/03/21 11:56:45 meskes Exp $ */
+/* $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/ecpg.trailer,v 1.24 2010/03/31 08:45:18 meskes Exp $ */
statements: /*EMPTY*/
| statements statement
@@ -296,8 +296,13 @@ ECPGCursorStmt: DECLARE cursor_name cursor_options CURSOR opt_hold FOR prepared
for (ptr = cur; ptr != NULL; ptr = ptr->next)
{
if (strcmp($2, ptr->name) == 0)
+ {
/* re-definition is a bug */
- mmerror(PARSE_ERROR, ET_ERROR, "cursor \"%s\" is already defined", $2);
+ if ($2[0] == ':')
+ mmerror(PARSE_ERROR, ET_ERROR, "using variable \"%s\" in different declare statements is not supported", $2+1);
+ else
+ mmerror(PARSE_ERROR, ET_ERROR, "cursor \"%s\" is already defined", $2);
+ }
}
this = (struct cursor *) mm_alloc(sizeof(struct cursor));