Re: XML/XPath issues: text/CDATA in XMLTABLE, XPath evaluated withwrong context - Mailing list pgsql-hackers

From Chapman Flack
Subject Re: XML/XPath issues: text/CDATA in XMLTABLE, XPath evaluated withwrong context
Date
Msg-id 5C788B58.9010202@anastigmatix.net
Whole thread Raw
In response to Re: XML/XPath issues: text/CDATA in XMLTABLE, XPath evaluated withwrong context  (Ramanarayana <raam.soft@gmail.com>)
List pgsql-hackers
Hi, thanks for checking the patches!

On 02/28/19 19:36, Ramanarayana wrote:
> The below statement needs to be executed before running the query to
> replicate the issue
> 
> update xmldata set data = regexp_replace(data::text, '791',
> '<!--ah-->7<!--oh-->9<!--uh-->1')::xml;

If you are applying that update (and there is a SIZE element originally
791), and then receiving a "more than one value returned by column XPath
expression" error, I believe you are seeing documented, correct behavior.

Your update changes the content of that SIZE element to have three
comment nodes and three text nodes.

The query then contains this column spec:

size_text float PATH 'SIZE/text()'

where the target SQL column type is 'float' and the path expression will
return an XML result consisting of the three text nodes.

As documented, "An XML result assigned to a column of any other type may
not have more than one node, or an error is raised."

So I think this behavior is correct.

If you do any more testing (thank you for taking the interest, by the way!),
could you please add your comments, not to this email thread, but to [1]?

[1]
https://www.postgresql.org/message-id/3e8eab9e-7289-6c23-5e2c-153cccea2257%40anastigmatix.net

That's the one that is registered to the commitfest entry, so comments made
on this thread might be overlooked.

Thanks!
-Chap


pgsql-hackers by date:

Previous
From: Nikita Glukhov
Date:
Subject: Re: SQL/JSON: JSON_TABLE
Next
From: Kyotaro HORIGUCHI
Date:
Subject: Re: FETCH FIRST clause PERCENT option