From e286783c61d24e4eb9bde056da6a76a21aab6afa Mon Sep 17 00:00:00 2001 From: Lee Dong Wook Date: Mon, 22 Aug 2022 22:42:38 +0900 Subject: [PATCH] xml2: add test for coverage --- contrib/xml2/expected/xml2.out | 36 ++++++++++++++++++++++++++++++++++ contrib/xml2/sql/xml2.sql | 8 ++++++++ 2 files changed, 44 insertions(+) diff --git a/contrib/xml2/expected/xml2.out b/contrib/xml2/expected/xml2.out index eba6ae603649..dd88e1747e30 100644 --- a/contrib/xml2/expected/xml2.out +++ b/contrib/xml2/expected/xml2.out @@ -88,6 +88,18 @@ as t(id int4, doc int4); 1 | 1 (1 row) +select * from xml_valid('xpath_test'); + xml_valid +----------- + t +(1 row) + +select xml_encode_special_chars('1'); + xml_encode_special_chars +------------------------------------------------- + <doc><int>1</int></doc> +(1 row) + create table articles (article_id integer, article_xml xml, date_entered date); insert into articles (article_id, article_xml, date_entered) values (2, '
test37
', now()); @@ -139,6 +151,30 @@ values Value'); create index idx_xpath on t1 ( xpath_string ('/attributes/attribute[@name="attr_1"]/text()', xml_data::text)); +select xpath_number('/attributes/attribute[@name="attr_1"]/', xml_data::text) from t1; + xpath_number +-------------- + +(1 row) + +select xpath_bool('/attributes/attribute[@name="attr_1"]/', xml_data::text) from t1; + xpath_bool +------------ + f +(1 row) + +select xpath_nodeset('/attributes/attribute[@name="attr_1"]/', xml_data::text) from t1; + xpath_nodeset +--------------- + +(1 row) + +select xpath_list('/attributes/attribute[@name="attr_1"]/', xml_data::text) from t1; + xpath_list +------------ + +(1 row) + SELECT xslt_process('cim30400'::text, $$ diff --git a/contrib/xml2/sql/xml2.sql b/contrib/xml2/sql/xml2.sql index ac49cfa7c523..2f1c2614f231 100644 --- a/contrib/xml2/sql/xml2.sql +++ b/contrib/xml2/sql/xml2.sql @@ -34,6 +34,9 @@ as t(id int4); SELECT * FROM xpath_table('id', 't', 'xpath_test', '/doc/int', 'true') as t(id int4, doc int4); +select * from xml_valid('xpath_test'); +select xml_encode_special_chars('1'); + create table articles (article_id integer, article_xml xml, date_entered date); insert into articles (article_id, article_xml, date_entered) values (2, '
test37
', now()); @@ -73,6 +76,11 @@ Value'); create index idx_xpath on t1 ( xpath_string ('/attributes/attribute[@name="attr_1"]/text()', xml_data::text)); +select xpath_number('/attributes/attribute[@name="attr_1"]/', xml_data::text) from t1; +select xpath_bool('/attributes/attribute[@name="attr_1"]/', xml_data::text) from t1; +select xpath_nodeset('/attributes/attribute[@name="attr_1"]/', xml_data::text) from t1; +select xpath_list('/attributes/attribute[@name="attr_1"]/', xml_data::text) from t1; + SELECT xslt_process('cim30400'::text, $$