Re: Patch Review: Bugfix for XPATH() if text or attribute nodes are selected
От | Radosław Smogura |
---|---|
Тема | Re: Patch Review: Bugfix for XPATH() if text or attribute nodes are selected |
Дата | |
Msg-id | cf964c14afa1bf7c60466b22fd45a71d@mail.softperience.eu обсуждение исходный текст |
Ответ на | Re: Patch Review: Bugfix for XPATH() if text or attribute nodes are selected (Robert Haas <robertmhaas@gmail.com>) |
Ответы |
Re: Patch Review: Bugfix for XPATH() if text or attribute nodes are selected
|
Список | pgsql-hackers |
On Sun, 10 Jul 2011 17:06:22 -0500, Robert Haas wrote: > On Jul 10, 2011, at 1:40 PM, Josh Berkus <josh@agliodbs.com> wrote: > >> Hackers, >> >>>> B. 6. Current behaviour _is intended_ (there is "if" to check >>>> node type) and _"natural"_. In this particular case user ask for >>>> text content of some node, and this content is actually "<". >>> >>> I don't buy that. The check for the node type is there because >>> two different libxml functions are used to convert nodes to >>> strings. The if has absolutely *zero* to do with escaping, expect >>> for that missing escape_xml() call in the "else" case. >>> >>> Secondly, there is little point in having an type XML if we >>> don't actually ensure that values of that type can only contain >>> well-formed XML. >> >> Can anyone else weigh in on this? Peter? > > Unless I am missing something, Florian is clearly correct here. > > ...RobertFor me not, because this should be fixed internally by making xml type sefe, currently xml type may be used tokeep proper XMLs and any kind of data, as well. If I ask, by any means select xpath(/text(...))..... I want to get text.1) How I should descape node in client application(if it's part of xml I don't have header), bear in mind XML must give support for streaming processing too.2)Why I should differntly treat text() then select from varchar in both I ask for xml, driver can't make this, becauseit doesn't know if it gets scalar, text, comment, element, or maybe document.3) What about current applications, folksprobably uses this and are happy they get text, and will not see, that next release of PostgreSQL will break their applications. There is of course disadvantage of current behaviour as it may lead to inserting badly xmls (in one case), but I createdexample when auto escaping will create double escaped xmls, and may lead to insert inproper data (this is about 2ndpatch where Florian add escaping, too). SELECT XMLELEMENT(name root, XMLATTRIBUTES(foo.namespace AS sth)) FROM (SELECT(XPATH('namespace-uri(/*)', x))[1] AS namespaceFROM (VALUES (XMLELEMENT(name"root", XMLATTRIBUTES('<n' AS xmlns, '<v' AS value),'<t'))) v(x)) as foo; xmlelement------------------------- <root sth="<n"/> It can't be resolved without storing type in xml or adding xmltext or adding pseudo xmlany element, which will be returnedby xpath. Regards,Radek
В списке pgsql-hackers по дате отправления: