From f6e0c4908ad99b03f2a5eeb5de793529d521b5da Mon Sep 17 00:00:00 2001 From: mrdrivingduck Date: Sun, 10 Mar 2024 15:13:49 +0800 Subject: [PATCH] bug: fix broken xml test cases --- src/test/regress/expected/xml.out | 52 ++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 12 deletions(-) diff --git a/src/test/regress/expected/xml.out b/src/test/regress/expected/xml.out index bffbce7ab48..c05f5d79733 100644 --- a/src/test/regress/expected/xml.out +++ b/src/test/regress/expected/xml.out @@ -9,6 +9,8 @@ ERROR: invalid XML content LINE 1: INSERT INTO xmltest VALUES (3, '', NULL, ''); xmlconcat -------------- @@ -105,9 +109,16 @@ SELECT xmlelement(name element, xmlelement(name nested, 'stuff')); (1 row) SELECT xmlelement(name employee, xmlforest(name, age, salary as pay)) FROM emp; -ERROR: relation "emp" does not exist -LINE 1: ...ame employee, xmlforest(name, age, salary as pay)) FROM emp; - ^ + xmlelement +---------------------------------------------------------------------- + sharon251000 + sam302000 + bill201000 + jeff23600 + cim30400 + linda19100 +(6 rows) + SELECT xmlelement(name duplicate, xmlattributes(1 as a, 2 as b, 3 as a)); ERROR: XML attribute name "a" appears more than once LINE 1: ...ment(name duplicate, xmlattributes(1 as a, 2 as b, 3 as a)); @@ -213,12 +224,16 @@ DETAIL: line 1: xmlParseEntityRef: no name & ^ line 1: chunk is not well balanced +& + ^ SELECT xmlparse(content '&idontexist;'); ERROR: invalid XML content DETAIL: line 1: Entity 'idontexist' not defined &idontexist; ^ line 1: chunk is not well balanced +&idontexist; + ^ SELECT xmlparse(content ''); xmlparse --------------------------- @@ -237,7 +252,11 @@ DETAIL: line 1: Entity 'idontexist' not defined &idontexist; ^ line 1: Opening and ending tag mismatch: twoerrors line 1 and unbalanced +&idontexist; + ^ line 1: chunk is not well balanced +&idontexist; + ^ SELECT xmlparse(content ''); xmlparse --------------------- @@ -247,6 +266,8 @@ SELECT xmlparse(content ''); 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 @@ -264,12 +285,16 @@ DETAIL: line 1: xmlParseEntityRef: no name & ^ line 1: Opening and ending tag mismatch: invalidentity line 1 and abc +& + ^ SELECT xmlparse(document '&idontexist;'); ERROR: invalid XML document DETAIL: line 1: Entity 'idontexist' not defined &idontexist; ^ line 1: Opening and ending tag mismatch: undefinedentity line 1 and abc +&idontexist; + ^ SELECT xmlparse(document ''); xmlparse --------------------------- @@ -288,6 +313,8 @@ DETAIL: line 1: Entity 'idontexist' not defined &idontexist; ^ line 1: Opening and ending tag mismatch: twoerrors line 1 and unbalanced +&idontexist; + ^ SELECT xmlparse(document ''); xmlparse --------------------- @@ -472,9 +499,11 @@ SELECT xmlagg(data) FROM xmltest WHERE id > 10; (1 row) SELECT xmlelement(name employees, xmlagg(xmlelement(name name, name))) FROM emp; -ERROR: relation "emp" does not exist -LINE 1: ...me employees, xmlagg(xmlelement(name name, name))) FROM emp; - ^ + xmlelement +-------------------------------------------------------------------------------------------------------------------------------- + sharonsambilljeffcimlinda +(1 row) + -- Check mapping SQL identifier to XML name SELECT xmlpi(name ":::_xml_abc135.%-&_"); xmlpi @@ -567,9 +596,6 @@ CREATE VIEW xmlview1 AS SELECT xmlcomment('test'); CREATE VIEW xmlview2 AS SELECT xmlconcat('hello', 'you'); CREATE VIEW xmlview3 AS SELECT xmlelement(name element, xmlattributes (1 as ":one:", 'deuce' as two), 'content&'); CREATE VIEW xmlview4 AS SELECT xmlelement(name employee, xmlforest(name, age, salary as pay)) FROM emp; -ERROR: relation "emp" does not exist -LINE 1: ...ame employee, xmlforest(name, age, salary as pay)) FROM emp; - ^ CREATE VIEW xmlview5 AS SELECT xmlparse(content 'x'); CREATE VIEW xmlview6 AS SELECT xmlpi(name foo, 'bar'); CREATE VIEW xmlview7 AS SELECT xmlroot(xml '', version no value, standalone yes); @@ -577,17 +603,19 @@ CREATE VIEW xmlview8 AS SELECT xmlserialize(content 'good' as char(10)); CREATE VIEW xmlview9 AS SELECT xmlserialize(content 'good' as text); SELECT table_name, view_definition FROM information_schema.views WHERE table_name LIKE 'xmlview%' ORDER BY 1; - table_name | view_definition -------------+------------------------------------------------------------------------------------------------------------ + table_name | view_definition +------------+------------------------------------------------------------------------------------------------------------------- xmlview1 | SELECT xmlcomment('test'::text) AS xmlcomment; xmlview2 | SELECT XMLCONCAT('hello'::xml, 'you'::xml) AS "xmlconcat"; xmlview3 | SELECT XMLELEMENT(NAME element, XMLATTRIBUTES(1 AS ":one:", 'deuce' AS two), 'content&') AS "xmlelement"; + xmlview4 | SELECT XMLELEMENT(NAME employee, XMLFOREST(emp.name AS name, emp.age AS age, emp.salary AS pay)) AS "xmlelement"+ + | FROM emp; xmlview5 | SELECT XMLPARSE(CONTENT 'x'::text STRIP WHITESPACE) AS "xmlparse"; xmlview6 | SELECT XMLPI(NAME foo, 'bar'::text) AS "xmlpi"; xmlview7 | SELECT XMLROOT(''::xml, VERSION NO VALUE, STANDALONE YES) AS "xmlroot"; xmlview8 | SELECT (XMLSERIALIZE(CONTENT 'good'::xml AS character(10)))::character(10) AS "xmlserialize"; xmlview9 | SELECT XMLSERIALIZE(CONTENT 'good'::xml AS text) AS "xmlserialize"; -(8 rows) +(9 rows) -- Text XPath expressions evaluation SELECT xpath('/value', data) FROM xmltest;