| From: | Jim Jones <jim(dot)jones(at)uni-muenster(dot)de> |
|---|---|
| To: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | XMLTable treats a column of a domain over xml as a non-xml column |
| Date: | 2026-11-07 20:30:04 |
| Message-ID: | 394579a3-4913-4d10-aacc-e84fe8e10584@uni-muenster.de |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi
XMLTable handles a column whose type is a domain over xml as if it were
a plain non-xml column:
== master ==
postgres=# create domain xmldom as xml;
CREATE DOMAIN
postgres=# select * from
xmltable('/r' passing '<r><a>x</a></r>'
columns c1 xml path 'a',
c2 xmldom path 'a');
c1 | c2
----------+----
<a>x</a> | x
(1 row)
Since xmldom in this examplw is a domain over xml, both columns should
return the same value,but c2 only gets the node's string value.
For boolean results xmltable already looks through domains:
postgres=# create domain intdom as int;
CREATE DOMAIN
postgres=# select * from
xmltable('/r' passing '<r/>'
columns c1 int path 'true()',
c2 intdom path 'true()',
c3 text path 'true()');
c1 | c2 | c3
----+----+------
1 | 1 | true
(1 row)
It picks 1/0 or true/false by type category,which a domain inherits, so
the intdom column behaves like the int column. The xml check should do
the same.
The cause is that XmlTableGetValue() tests typid == XMLOID, which does
not consider domains. The attached patch resolves domains to their base
type with getBaseType() before that test, and adds a regression test.
== patched ==
postgres=# select * from
xmltable('/r' passing '<r><a>x</a></r>'
columns c1 xml path 'a',
c2 xmldom path 'a');
c1 | c2
----------+----------
<a>x</a> | <a>x</a>
(1 row)
Best, Jim
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Treat-domains-over-xml-like-xml-in-XMLTABLE-colum.patch | text/x-patch | 3.2 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Lukas Fittl | 2026-11-07 20:36:22 | Re: PostgreSQL 19 GA press release draft |
| Previous Message | Jonathan S. Katz | 2026-11-07 20:22:50 | Re: PostgreSQL 19 GA press release draft |