Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
3a32ba2f
Commit
3a32ba2f
authored
Jan 08, 2007
by
Peter Eisentraut
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevent duplicate attribute names in XMLELEMENT.
parent
19f9376b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
4 deletions
+25
-4
src/backend/parser/parse_expr.c
src/backend/parser/parse_expr.c
+19
-3
src/test/regress/expected/xml.out
src/test/regress/expected/xml.out
+3
-1
src/test/regress/expected/xml_1.out
src/test/regress/expected/xml_1.out
+2
-0
src/test/regress/sql/xml.sql
src/test/regress/sql/xml.sql
+1
-0
No files found.
src/backend/parser/parse_expr.c
View file @
3a32ba2f
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.20
4 2007/01/05 22:19:34 momjian
Exp $
* $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.20
5 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
;
...
...
src/test/regress/expected/xml.out
View file @
3a32ba2f
...
...
@@ -65,7 +65,7 @@ SELECT xmlelement(name element,
SELECT xmlelement(name element,
xmlattributes ('unnamed and wrong'));
ERROR: unnamed attribute value must be a column reference
ERROR: unnamed
XML
attribute value must be a column reference
SELECT xmlelement(name element, xmlelement(name nested, 'stuff'));
xmlelement
-------------------------------------------
...
...
@@ -85,6 +85,8 @@ SELECT xmlelement(name employee, xmlforest(name, age, salary as pay)) FROM emp;
SELECT xmlelement(name wrong, 37);
ERROR: argument of XMLELEMENT must be type xml, not type integer
SELECT xmlelement(name duplicate, xmlattributes(1 as a, 2 as b, 3 as a));
ERROR: XML attribute name "a" appears more than once
SELECT xmlparse(content 'abc');
xmlparse
----------
...
...
src/test/regress/expected/xml_1.out
View file @
3a32ba2f
...
...
@@ -46,6 +46,8 @@ SELECT xmlelement(name employee, xmlforest(name, age, salary as pay)) FROM emp;
ERROR: no XML support in this installation
SELECT xmlelement(name wrong, 37);
ERROR: no XML support in this installation
SELECT xmlelement(name duplicate, xmlattributes(1 as a, 2 as b, 3 as a));
ERROR: no XML support in this installation
SELECT xmlparse(content 'abc');
ERROR: no XML support in this installation
SELECT xmlparse(content '<abc>x</abc>');
...
...
src/test/regress/sql/xml.sql
View file @
3a32ba2f
...
...
@@ -38,6 +38,7 @@ SELECT xmlelement(name element, xmlelement(name nested, 'stuff'));
SELECT
xmlelement
(
name
employee
,
xmlforest
(
name
,
age
,
salary
as
pay
))
FROM
emp
;
SELECT
xmlelement
(
name
wrong
,
37
);
SELECT
xmlelement
(
name
duplicate
,
xmlattributes
(
1
as
a
,
2
as
b
,
3
as
a
));
SELECT
xmlparse
(
content
'abc'
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment