]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix handling of namespace nodes in xpath() (xml)
authorMichael Paquier <michael@paquier.xyz>
Fri, 12 Jun 2026 01:25:45 +0000 (10:25 +0900)
committerMichael Paquier <michael@paquier.xyz>
Fri, 12 Jun 2026 01:25:45 +0000 (10:25 +0900)
commit8bf257aebac12791dc78a599e4f7dc225893d45e
tree3bcdb60f44e38deb91091ab3d1034da50b5928ca
parent389bd4c5b93426e6616a0be7cff9cf91179c16e7
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
src/backend/utils/adt/xml.c
src/test/regress/expected/xml.out
src/test/regress/expected/xml_1.out
src/test/regress/sql/xml.sql