Skip site navigation (1) Skip section navigation (2)

Re: XMLATTRIBUTES vs. values of type XML

From: Florian Pflug <fgp(at)phlo(dot)org>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: XMLATTRIBUTES vs. values of type XML
Date: 2011-07-27 21:21:39
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
On Jul27, 2011, at 23:08 , Peter Eisentraut wrote:
> Well, offhand I would expect that passing an XML value to XMLATTRIBUTES
> would behave as in

With both 9.1 and 9.2 this query returns

 <t a="&amp;amp;"/>

i.e. makes the value of "a" represent the *literal* string '&amp;', *not*
the literal string '&'. Just to be sure there's no miss-understanding here
- is this what you expect?

> which is what it indeed does in 9.1.
> So if we don't want to restrict this, for backward compatibility, then I
> would suggest that we fix it to work like it used to.

There's currently no difference in behaviour between 9.1 and 9.2 there.
We've only modified XPATH to always correctly escape it's result in 9.2,
so there's only a difference if you pass the result of XPATH() to
XMLATTRIBUTES. Which I figured to be the most likely reason for to pass
values of type XML to XMLATTRIBUTES, but maybe you disagree there.

> I would be very hesitant about adding another escape mechanism that
> escapes some things but not others.  We already have two or three of
> those for XML, and it doesn't seem worth adding another one just for
> this, which is outside the standard and for which a valid workaround
> exists.

What's the workaround if you have a value of type XML, e.g. '&amp;',
and want to set an attribute to the value represented by that XML fragment
(i.e. '&')? Since we have no XMLUNESCAPE function, I don't see an easy
way to do that. Maybe I'm missing something, though.

best regards,
Florian Pflug

In response to


pgsql-hackers by date

Next:From: Florian PflugDate: 2011-07-27 21:37:15
Subject: Is a heads-up in 9.1 in order regarding the XML-related changes in 9.2?
Previous:From: Pavel StehuleDate: 2011-07-27 21:20:37
Subject: Re: patch for 9.2: enhanced errors

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group