Re: XMLDocument (SQL/XML X030)

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: XMLDocument (SQL/XML X030)
Date: 2025-01-14 08:14:34
Message-ID: CAFj8pRAimDAMChsZNKQksz209gqpQ13dcnbGwr7LRH0dgso=ng@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

út 14. 1. 2025 v 8:11 odesílatel Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
napsal:

> Hi,
>
> I'd like to propose the implementation of XMLDocument (SQL/XML X030).It
> basically returns an XML document from a given XML expression, e.g.
>
> SELECT
> xmldocument(
> xmlelement(NAME foo,
> xmlattributes(42 AS att),
> xmlelement(NAME bar,
> xmlconcat('va', 'lue'))
> )
> );
>
> xmldocument
> --------------------------------------
> <foo att="42"><bar>value</bar></foo>
> (1 row)
>
> XMLDocument doesn't do much. In fact, it might be reduced to a simple
> xmlparse() call as XMLOPTION_DOCUMENT...
>
> xmlparse(data, XMLOPTION_DOCUMENT, true)
>
> ... to make sure that the given XML expression is a valid document -
> still need some more research there. One could argue that XMLDocument()
> is in most cases unnecessary, but I believe it would facilitate the
> migration of scripts from other database products.
>
> Any thoughts?
>

I did some research and the design of this document is different

1. Oracle doesn't support this
2. DB2 has different implementations for z/OS (variadic) and for unix
(nonvariadic)
3. looks so db2 allows some concatenation of xml content when xmlexpr is
not the document already (not tested)
4. Your implementation just raise an exception

I didn't find a free downloadable SQL/XML standard with description of
XMLDOCUMENT so I read just the DB2 doc, but it isn't fully consistent and
it is different from your implementation.
So the argument of better compatibility for this patch doesn't look too
strong. But I found that the usage of XMLDOCUMENT is required for storing
XML, so it can be a frequently used function. Unfortunately, I do not have
any knowledge about db2. It is hard to understand the usage of this
function, because the sense is probably different than in DB2, and the
documentation doesn't explain well an usage and motivation for this
function. If it does a check, then it is not described in doc.

Regards

Pavel

> Best, Jim
>
>
>
>
>
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Yugo NAGATA 2025-01-14 08:44:08 Re: psql: Add leakproof field to \dAo+ meta-command results
Previous Message Hunaid Sohail 2025-01-14 07:57:29 Re: Psql meta-command conninfo+