]> granicus.if.org Git - postgresql/commit
Accept XML documents when xmloption = content, as required by SQL:2006+.
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 23 Mar 2019 20:24:30 +0000 (16:24 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 23 Mar 2019 20:24:30 +0000 (16:24 -0400)
commit849f87a1c3346df65d0e21b2d4b1c296a61495d5
treec0afffbc1f6e62fdc502767e69d6e4f2bb9daa8f
parent04f9b449aa309410dbbcbf4951802a3f73b42bd0
Accept XML documents when xmloption = content, as required by SQL:2006+.

Previously we were using the SQL:2003 definition, which doesn't allow
this, but that creates a serious dump/restore gotcha: there is no
setting of xmloption that will allow all valid XML data.  Hence,
switch to the 2006 definition.

Since libxml doesn't accept <!DOCTYPE> directives in the mode we
use for CONTENT parsing, the implementation is to detect <!DOCTYPE>
in the input and switch to DOCUMENT parsing mode.  This should not
cost much, because <!DOCTYPE> should be close to the front of the
input if it's there at all.  It's possible that this causes the
error messages for malformed input to be slightly different than
they were before, if said input includes <!DOCTYPE>; but that does
not seem like a big problem.

In passing, buy back a few cycles in parsing of large XML documents
by not doing strlen() of the whole input in parse_xml_decl().

Back-patch because dump/restore failures are not nice.  This change
shouldn't break any cases that worked before, so it seems safe to
back-patch.

Chapman Flack (revised a bit by me)

Discussion: https://postgr.es/m/CAN-V+g-6JqUQEQZ55Q3toXEN6d5Ez5uvzL4VR+8KtvJKj31taw@mail.gmail.com
doc/src/sgml/datatype.sgml
src/backend/utils/adt/xml.c
src/test/regress/expected/xml.out
src/test/regress/expected/xml_1.out
src/test/regress/expected/xml_2.out
src/test/regress/sql/xml.sql