Re: XML/XPath issues: text/CDATA in XMLTABLE, XPath evaluated with wrong context

From: Chapman Flack <chap(at)anastigmatix(dot)net>
To: Ramanarayana <raam(dot)soft(at)gmail(dot)com>, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
Cc: Markus Winand <markus(dot)winand(at)winand(dot)at>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Subject: Re: XML/XPath issues: text/CDATA in XMLTABLE, XPath evaluated with wrong context
Date: 2019-03-01 01:31:04
Message-ID: 5C788B58.9010202@anastigmatix.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Kyotaro HORIGUCHI 2019-03-01 01:31:45 Re: FETCH FIRST clause PERCENT option
Previous Message Nikita Glukhov 2019-03-01 01:19:38 Re: SQL/JSON: JSON_TABLE