Re: [REVIEW] Re: Fix xpath() to return namespace definitions - Mailing list pgsql-hackers

From Ali Akbar
Subject Re: [REVIEW] Re: Fix xpath() to return namespace definitions
Date
Msg-id CACQjQLotP6K+HcnZk9PbPzQc6HUo8mDZDHoY8zEGkoVdDHbuBg@mail.gmail.com
Whole thread Raw
In response to Re: [REVIEW] Re: Fix xpath() to return namespace definitions  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: [REVIEW] Re: Fix xpath() to return namespace definitions
List pgsql-hackers
Peter Eisentraut <peter_e@gmx.net> writes:
> committed version 7
Thanks!

2015-01-07 13:28 GMT+07:00 Tom Lane <tgl@sss.pgh.pa.us>:
Isn't that a back-patchable bug fix?

Upthread, i noted:
For back versions, i think because this patch changes xpath() behavior, we will only apply this to future versions. The old behavior is wrong (according to XPath standard) for not including namespaces, but maybe there are some application that depends on the old behavior.

Reviewing the behavior on 9.3, now i think the old behavior isn't usable (the resulting xml is not even processable in postgres):

# select unnest(xpath('//a:b', '<b:a xmlns:b="http://test.com/a"><b:b>1</b:b><b:b>2</b:b></b:a>'::xml, array[array['a','http://test.com/a']]));
    unnest   
--------------
 <b:b>1</b:b>
 <b:b>2</b:b>
(2 rows)

# select xpath('//b:b', unnest(xpath('//a:b', '<b:a xmlns:b="http://test.com/a"><b:b>1</b:b><b:b>2</b:b></b:a>'::xml, array[array['a','http://test.com/a']])));
ERROR:  could not parse XML document
DETAIL:  line 1: Namespace prefix b on b is not defined
<b:b>1</b:b>

Maybe some application uses the result directly, but correct xml-using applications should handle namespace correctly, so if '<b:b>1</b:b>' becomes '<b:b xmlns:b="http://test.com/a' >1</b:b>', there should be no issue in those applications.


So now +1 for back-patching this.

Regards,
--
Ali Akbar

pgsql-hackers by date:

Previous
From: David Fetter
Date:
Subject: Re: INSERT ... ON CONFLICT UPDATE and RLS
Next
From: Peter Geoghegan
Date:
Subject: Re: INSERT ... ON CONFLICT UPDATE and RLS