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-16 06:11:32 |
Message-ID: | CAFj8pRCKQY5vkhaKT72GoeGuHj1g7+bCY95V3pSGY=j2fAnn1w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
st 15. 1. 2025 v 22:05 odesílatel Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
napsal:
> Hi Pavel
>
> On 14.01.25 09:14, Pavel Stehule wrote:
> > 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'm not entirely sure I follow. XMLDOCUMENT is designed to produce a
> well-formed XML document, and according to the XML specification, a
> well-formed document must have precisely one root element.
>
>
> SELECT
> xmlserialize(DOCUMENT
> xmldocument(
> xmlelement(NAME root,
> xmlattributes(42 AS att),
> xmlcomment('comment'),
> xmlelement(NAME foo,'<foo&bar>'),
> xmlelement(NAME bar,
> xmlconcat('va', 'lue')),
> xmlpi(name pi),
> xmlelement(NAME txt, xmltext('<"&>'))
> )) AS text INDENT) ;
> xmlserialize
> ----------------------------------
> <root att="42"> +
> <!--comment--> +
> <foo><foo&bar></foo>+
> <bar>value</bar> +
> <?pi?> +
> <txt><"&></txt> +
> </root>
> (1 row)
>
>
> Could you provide an example of this feature you're missing?
>
> Malformed CONTENT xml strings will indeed raise an exception.
>
> SELECT xmldocument('foo'::xml);
> ERROR: invalid XML document
> DETAIL: line 1: Start tag expected, '<' not found
> foo
> ^
>
> >
> > 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.
>
>
> The main idea is to ensure that an xml string is a valid document (even
> in CONTENT mode)
>
> postgres=# SET xmloption TO DOCUMENT;
> SET
> postgres=# SELECT 'foo'::xml;
> ERROR: invalid XML document
> LINE 1: SELECT 'foo'::xml;
> ^
> DETAIL: line 1: Start tag expected, '<' not found
> foo
> ^
> postgres=# SET xmloption TO CONTENT;
> SET
> postgres=# SELECT 'foo'::xml;
> xml
> -----
> foo
> (1 row)
>
> postgres=# SELECT xmldocument('foo'::xml);
> ERROR: invalid XML document
> DETAIL: line 1: Start tag expected, '<' not found
> foo
> ^
>
> > 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.
> >
> Perhaps changing the documentation like this would make things clearer?
>
> "The xmldocument function encapsulates the XML expression within a valid
> XML document structure. The expression passed as the argument must be a
> valid, single-rooted XML fragment. If the XML expression is NULL, the
> result will also be NULL."
>
It is better.
My note was related to a very different description of this functionality
in DB2. So if you propose this function for better compatibility (and this
function is implemented only by db2), it is surprising to see that this
functionality is described (and probably implemented) very differently.
Because I do not have db2 and I miss db2 knowledge, I don't know if
differences in implementation and description are based on different
technology (XML like graph or XML like string) or if it is something that
is missing in this patch.
Regards
Pavel
>
> Many thanks for the review!
>
> Best, Jim
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Andy Fan | 2025-01-16 06:30:46 | Re: Purpose of wal_init_zero |
Previous Message | Yugo Nagata | 2025-01-16 06:04:38 | Re: Inquiry About Determining Parallel Plans for REFRESH MATERIALIZED VIEW |