agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: Michael Paquier <michael@paquier.xyz>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix handling of namespace nodes in xpath() (xml)
Date: Fri, 12 Jun 2026 01:26:34 +0000
Message-ID: <E1wXqfK-0025Qc-21@gemulon.postgresql.org> (raw)

Fix handling of namespace nodes in xpath() (xml)

xpath() attempted to call xmlCopyNode() and xmlNodeDump() on a
XML_NAMESPACE_DECL, finishing with a confusing error:
=# SELECT xpath('//namespace::foo', '<root xmlns:foo="http://127.0.0.1"/>';);
ERROR:  53200: could not copy node
CONTEXT:  SQL function "xpath" statement 1

xpath() is changed so as it goes through xmlXPathCastNodeToString()
instead, that is able to handle namespace nodes.  xml2 uses the same
solution.  This issue has been discovered while digging into
9d33a5a804db.

Author: Michael Paquier <michael@paquier.xyz>
Discussion: https://postgr.es/m/aioT7ui_ZJ9RMlfM@paquier.xyz
Backpatch-through: 14

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/1d8c72b2eff61202f3b35c0c130a52231cb3590a

Modified Files
--------------
src/backend/utils/adt/xml.c         | 4 +++-
src/test/regress/expected/xml.out   | 6 ++++++
src/test/regress/expected/xml_1.out | 5 +++++
src/test/regress/sql/xml.sql        | 1 +
4 files changed, 15 insertions(+), 1 deletion(-)



view thread (6+ messages)  latest in thread

Message-ID: <E1wXqfK-0025Qc-21@gemulon.postgresql.org>
Permalink:  ../E1wXqfK-0025Qc-21@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1wXqfK-0025Qc-21@gemulon.postgresql.org

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: michael@paquier.xyz, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Fix handling of namespace nodes in xpath() (xml)
  In-Reply-To: <E1wXqfK-0025Qc-21@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox