[PATCH] Bug in XPATH() if expression returns a scalar value

Поиск
Список
Период
Сортировка
От Florian Pflug
Тема [PATCH] Bug in XPATH() if expression returns a scalar value
Дата
Msg-id 33B182D9-D2C3-4BDF-A8C9-B896BC9B8629@phlo.org
обсуждение исходный текст
Ответы Re: [PATCH] Bug in XPATH() if expression returns a scalar value
Список pgsql-hackers
Hi

The in-core XPATH() function currently only handles XPath expressions which
return a node set correctly. For XPath expressions which return boolean,
numeric or string values, XPATH() returns an empty array. (This is the case
for XPath expressions whose top-level syntactic construct isn't a path
expression but rather one of the built-in functions like name() or count()).

The XPath expression 'name(/*)', for example, is supposed to return 'root'
when applied to the XML fragment '<root><nested/><nested/></root>'. Postgres,
however, currently returns an empty array.

A patch which fixes that is attached. It makes XPATH() return a single-element
array containing a textual representation of the string, numeric value or boolean
for XPath expressions which don't return a node set. For numeric and boolean
results, the textual representation is obtained by calling float8out() respectively
boolout(). These function's results are assumed to always be well-form XML. For
string results, xml_in() is used to verify that the string returned by the XPath
expression is a well-formed XML fragment. This is required because XPATH() could
otherwise be used to insert invalid XML fragments into columns of type XML.

The patch add a few tests of non-nodeset returning XPath expressions to the
XML regression tests.

I'm not 100% clear on whether I should add this to the next commit fest or not -
after all, it's more a bug-fix rather than a new feature. But to prevent this
from getting lost, I'll add it unless someone tells me not to.

best regards,
Florian Pflug

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: Getting a bug tracker for the Postgres project
Следующее
От: Greg Smith
Дата:
Сообщение: Re: How can I check the treatment of bug fixes?