Trim regression test expected output for xml

This commit reduces the number of expected output files for the "xml"
test from three to two (well, mostly one, see below for details).

xml_2.out existed to handle some differences in output due to libxml2
2.9.3, due to some error context missing (085423e3e3).  This file is
removed, by tweaking the XML inputs to trigger the same error patterns
for the problematic 2.9.3 and other libxml2 versions.  This part is
authored by Tom Lane.

xml_1.out (no libxml2 support) is reduced in size by adding an \if query
that exits the test early.  This still checks NO_XML_SUPPORT() through
xmlin().  The rest of the test is skipped if XML input cannot be
handled by the backend.  This part has been written by me.

Author: Tom Lane <tgl@sss.pgh.pa.us>
Author: Michael Paquier <michael@paquier.xyz>
Reviewed-by: Daniel Gustafsson <daniel@yesql.se>
Discussion: https://postgr.es/m/aiu6CXO67q-s70n5@paquier.xyz
Backpatch-through: 14
This commit is contained in:
Michael Paquier 2026-06-15 11:37:55 +09:00
parent b4db796b19
commit e592535d22
4 changed files with 52 additions and 3393 deletions

View file

@ -4,13 +4,19 @@ CREATE TABLE xmltest (
);
INSERT INTO xmltest VALUES (1, '<value>one</value>');
INSERT INTO xmltest VALUES (2, '<value>two</value>');
INSERT INTO xmltest VALUES (3, '<wrong');
INSERT INTO xmltest VALUES (3, '<value>three</wrong> ');
ERROR: invalid XML content
LINE 1: INSERT INTO xmltest VALUES (3, '<wrong');
LINE 1: INSERT INTO xmltest VALUES (3, '<value>three</wrong> ');
^
DETAIL: line 1: Couldn't find end of Start Tag wrong line 1
<wrong
^
DETAIL: line 1: Opening and ending tag mismatch: value line 1 and wrong
<value>three</wrong>
^
-- If no XML data could be inserted, skip the tests as the server has been
-- compiled without libxml support.
SELECT count(*) = 0 AS skip_test FROM xmltest \gset
\if :skip_test
\quit
\endif
SELECT * FROM xmltest;
id | data
----+--------------------
@ -89,13 +95,13 @@ SELECT xmlconcat(1, 2);
ERROR: argument of XMLCONCAT must be type xml, not type integer
LINE 1: SELECT xmlconcat(1, 2);
^
SELECT xmlconcat('bad', '<syntax');
SELECT xmlconcat('bad', '<wrong></syntax> ');
ERROR: invalid XML content
LINE 1: SELECT xmlconcat('bad', '<syntax');
LINE 1: SELECT xmlconcat('bad', '<wrong></syntax> ');
^
DETAIL: line 1: Couldn't find end of Start Tag syntax line 1
<syntax
^
DETAIL: line 1: Opening and ending tag mismatch: wrong line 1 and syntax
<wrong></syntax>
^
SELECT xmlconcat('<foo/>', NULL, '<?xml version="1.1" standalone="no"?><bar/>');
xmlconcat
--------------
@ -271,13 +277,13 @@ SELECT xmlparse(content '<relativens xmlns=''relative''/>');
<relativens xmlns='relative'/>
(1 row)
SELECT xmlparse(content '<twoerrors>&idontexist;</unbalanced>');
SELECT xmlparse(content '<twoerrors>&idontexist;</unbalanced> ');
ERROR: invalid XML content
DETAIL: line 1: Entity 'idontexist' not defined
<twoerrors>&idontexist;</unbalanced>
<twoerrors>&idontexist;</unbalanced>
^
line 1: Opening and ending tag mismatch: twoerrors line 1 and unbalanced
<twoerrors>&idontexist;</unbalanced>
<twoerrors>&idontexist;</unbalanced>
^
SELECT xmlparse(content '<nosuchprefix:tag/>');
xmlparse
@ -285,11 +291,11 @@ SELECT xmlparse(content '<nosuchprefix:tag/>');
<nosuchprefix:tag/>
(1 row)
SELECT xmlparse(document ' ');
SELECT xmlparse(document '!');
ERROR: invalid XML document
DETAIL: line 1: Start tag expected, '<' not found
^
!
^
SELECT xmlparse(document 'abc');
ERROR: invalid XML document
DETAIL: line 1: Start tag expected, '<' not found
@ -301,21 +307,21 @@ SELECT xmlparse(document '<abc>x</abc>');
<abc>x</abc>
(1 row)
SELECT xmlparse(document '<invalidentity>&</abc>');
SELECT xmlparse(document '<invalidentity>&</abc> ');
ERROR: invalid XML document
DETAIL: line 1: xmlParseEntityRef: no name
<invalidentity>&</abc>
<invalidentity>&</abc>
^
line 1: Opening and ending tag mismatch: invalidentity line 1 and abc
<invalidentity>&</abc>
<invalidentity>&</abc>
^
SELECT xmlparse(document '<undefinedentity>&idontexist;</abc>');
SELECT xmlparse(document '<undefinedentity>&idontexist;</abc> ');
ERROR: invalid XML document
DETAIL: line 1: Entity 'idontexist' not defined
<undefinedentity>&idontexist;</abc>
<undefinedentity>&idontexist;</abc>
^
line 1: Opening and ending tag mismatch: undefinedentity line 1 and abc
<undefinedentity>&idontexist;</abc>
<undefinedentity>&idontexist;</abc>
^
SELECT xmlparse(document '<invalidns xmlns=''&lt;''/>');
xmlparse
@ -329,13 +335,13 @@ SELECT xmlparse(document '<relativens xmlns=''relative''/>');
<relativens xmlns='relative'/>
(1 row)
SELECT xmlparse(document '<twoerrors>&idontexist;</unbalanced>');
SELECT xmlparse(document '<twoerrors>&idontexist;</unbalanced> ');
ERROR: invalid XML document
DETAIL: line 1: Entity 'idontexist' not defined
<twoerrors>&idontexist;</unbalanced>
<twoerrors>&idontexist;</unbalanced>
^
line 1: Opening and ending tag mismatch: twoerrors line 1 and unbalanced
<twoerrors>&idontexist;</unbalanced>
<twoerrors>&idontexist;</unbalanced>
^
SELECT xmlparse(document '<nosuchprefix:tag/>');
xmlparse

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -5,7 +5,14 @@ CREATE TABLE xmltest (
INSERT INTO xmltest VALUES (1, '<value>one</value>');
INSERT INTO xmltest VALUES (2, '<value>two</value>');
INSERT INTO xmltest VALUES (3, '<wrong');
INSERT INTO xmltest VALUES (3, '<value>three</wrong> ');
-- If no XML data could be inserted, skip the tests as the server has been
-- compiled without libxml support.
SELECT count(*) = 0 AS skip_test FROM xmltest \gset
\if :skip_test
\quit
\endif
SELECT * FROM xmltest;
@ -30,7 +37,7 @@ SELECT xmlconcat(xmlcomment('hello'),
SELECT xmlconcat('hello', 'you');
SELECT xmlconcat(1, 2);
SELECT xmlconcat('bad', '<syntax');
SELECT xmlconcat('bad', '<wrong></syntax> ');
SELECT xmlconcat('<foo/>', NULL, '<?xml version="1.1" standalone="no"?><bar/>');
SELECT xmlconcat('<?xml version="1.1"?><foo/>', NULL, '<?xml version="1.1" standalone="no"?><bar/>');
SELECT xmlconcat(NULL);
@ -75,17 +82,17 @@ SELECT xmlparse(content '<invalidentity>&</invalidentity>');
SELECT xmlparse(content '<undefinedentity>&idontexist;</undefinedentity>');
SELECT xmlparse(content '<invalidns xmlns=''&lt;''/>');
SELECT xmlparse(content '<relativens xmlns=''relative''/>');
SELECT xmlparse(content '<twoerrors>&idontexist;</unbalanced>');
SELECT xmlparse(content '<twoerrors>&idontexist;</unbalanced> ');
SELECT xmlparse(content '<nosuchprefix:tag/>');
SELECT xmlparse(document ' ');
SELECT xmlparse(document '!');
SELECT xmlparse(document 'abc');
SELECT xmlparse(document '<abc>x</abc>');
SELECT xmlparse(document '<invalidentity>&</abc>');
SELECT xmlparse(document '<undefinedentity>&idontexist;</abc>');
SELECT xmlparse(document '<invalidentity>&</abc> ');
SELECT xmlparse(document '<undefinedentity>&idontexist;</abc> ');
SELECT xmlparse(document '<invalidns xmlns=''&lt;''/>');
SELECT xmlparse(document '<relativens xmlns=''relative''/>');
SELECT xmlparse(document '<twoerrors>&idontexist;</unbalanced>');
SELECT xmlparse(document '<twoerrors>&idontexist;</unbalanced> ');
SELECT xmlparse(document '<nosuchprefix:tag/>');