aboutsummaryrefslogtreecommitdiff
path: root/src/backend/parser/parse_expr.c
diff options
context:
space:
mode:
authorPeter Eisentraut <peter_e@gmx.net>2007-01-08 23:41:57 +0000
committerPeter Eisentraut <peter_e@gmx.net>2007-01-08 23:41:57 +0000
commit3a32ba2f3f54378e3e06366a5ff06e339984f065 (patch)
treed6c1c1d958b225a995a871f2e95c2dbc46c41f15 /src/backend/parser/parse_expr.c
parent19f9376bf48216f421849ba3edf123de5df36364 (diff)
downloadpostgresql-3a32ba2f3f54378e3e06366a5ff06e339984f065.tar.gz
postgresql-3a32ba2f3f54378e3e06366a5ff06e339984f065.zip
Prevent duplicate attribute names in XMLELEMENT.
Diffstat (limited to 'src/backend/parser/parse_expr.c')
-rw-r--r--src/backend/parser/parse_expr.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/backend/parser/parse_expr.c b/src/backend/parser/parse_expr.c
index c15858fc7a1..033dd6c75cf 100644
--- a/src/backend/parser/parse_expr.c
+++ b/src/backend/parser/parse_expr.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.204 2007/01/05 22:19:34 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.205 2007/01/08 23:41:56 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1415,8 +1415,8 @@ transformXmlExpr(ParseState *pstate, XmlExpr *x)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
x->op == IS_XMLELEMENT
- ? errmsg("unnamed attribute value must be a column reference")
- : errmsg("unnamed element value must be a column reference")));
+ ? errmsg("unnamed XML attribute value must be a column reference")
+ : errmsg("unnamed XML element value must be a column reference")));
argname = NULL; /* keep compiler quiet */
}
@@ -1424,6 +1424,22 @@ transformXmlExpr(ParseState *pstate, XmlExpr *x)
newx->arg_names = lappend(newx->arg_names, makeString(argname));
}
+ if (x->op == IS_XMLELEMENT)
+ {
+ foreach(lc, newx->arg_names)
+ {
+ ListCell *lc2;
+
+ for_each_cell(lc2, lnext(lc))
+ {
+ if (strcmp(strVal(lfirst(lc)), strVal(lfirst(lc2))) == 0)
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("XML attribute name \"%s\" appears more than once", strVal(lfirst(lc)))));
+ }
+ }
+ }
+
/* The other arguments are of varying types depending on the function */
newx->args = NIL;
i = 0;