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

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix handling of namespace nodes in xpath() (xml)
Date: 2026-06-12 01:26:34
Message-ID: E1wXqfK-0025QX-1u@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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(at)paquier(dot)xyz>
Discussion: https://postgr.es/m/aioT7ui_ZJ9RMlfM@paquier.xyz
Backpatch-through: 14

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/6c08cbb7a7b45171f058641c553210cd3261fe6c

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(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Amit Langote 2026-06-12 01:37:53 pgsql: Fix out-of-bounds write in RI fast-path batch on re-entry
Previous Message Fujii Masao 2026-06-12 00:40:31 pgsql: amcheck: Fix missing allequalimage corruption report