diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/regress/expected/xml.out | 30 | ||||
-rw-r--r-- | src/test/regress/expected/xml_1.out | 15 | ||||
-rw-r--r-- | src/test/regress/sql/xml.sql | 8 |
3 files changed, 53 insertions, 0 deletions
diff --git a/src/test/regress/expected/xml.out b/src/test/regress/expected/xml.out index 97c30600e84..189c22113b3 100644 --- a/src/test/regress/expected/xml.out +++ b/src/test/regress/expected/xml.out @@ -401,3 +401,33 @@ SELECT table_name, view_definition FROM information_schema.views xmlview9 | SELECT XMLSERIALIZE(CONTENT 'good'::"xml" AS text) AS "xmlserialize"; (9 rows) +-- Text XPath expressions evaluation +SELECT xmlpath('/value', data) FROM xmltest; + xmlpath +--------- + {one} + {two} +(2 rows) + +SELECT xmlpath(NULL, NULL) IS NULL FROM xmltest; + ?column? +---------- + t + t +(2 rows) + +SELECT xmlpath('', '<!-- error -->'); +ERROR: empty XPath expression +CONTEXT: SQL function "xmlpath" statement 1 +SELECT xmlpath('//text()', '<local:data xmlns:local="http://127.0.0.1"><local:piece id="1">number one</local:piece><local:piece id="2" /></local:data>'); + xmlpath +---------------- + {"number one"} +(1 row) + +SELECT xmlpath('//loc:piece/@id', '<local:data xmlns:local="http://127.0.0.1"><local:piece id="1">number one</local:piece><local:piece id="2" /></local:data>', ARRAY[ARRAY['loc'], ARRAY['http://127.0.0.1']]); + xmlpath +--------- + {1,2} +(1 row) + diff --git a/src/test/regress/expected/xml_1.out b/src/test/regress/expected/xml_1.out index 95b9d736151..3ba6e58d2d8 100644 --- a/src/test/regress/expected/xml_1.out +++ b/src/test/regress/expected/xml_1.out @@ -197,3 +197,18 @@ SELECT table_name, view_definition FROM information_schema.views xmlview5 | SELECT XMLPARSE(CONTENT '<abc>x</abc>'::text STRIP WHITESPACE) AS "xmlparse"; (2 rows) +-- Text XPath expressions evaluation +SELECT xmlpath('/value', data) FROM xmltest; + xmlpath +--------- +(0 rows) + +SELECT xmlpath(NULL, NULL) IS NULL FROM xmltest; +ERROR: no XML support in this installation +CONTEXT: SQL function "xmlpath" statement 1 +SELECT xmlpath('', '<!-- error -->'); +ERROR: no XML support in this installation +SELECT xmlpath('//text()', '<local:data xmlns:local="http://127.0.0.1"><local:piece id="1">number one</local:piece><local:piece id="2" /></local:data>'); +ERROR: no XML support in this installation +SELECT xmlpath('//loc:piece/@id', '<local:data xmlns:local="http://127.0.0.1"><local:piece id="1">number one</local:piece><local:piece id="2" /></local:data>', ARRAY[ARRAY['loc'], ARRAY['http://127.0.0.1']]); +ERROR: no XML support in this installation diff --git a/src/test/regress/sql/xml.sql b/src/test/regress/sql/xml.sql index 6ed9d8c47a2..32ac15610c7 100644 --- a/src/test/regress/sql/xml.sql +++ b/src/test/regress/sql/xml.sql @@ -144,3 +144,11 @@ 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; + +-- Text XPath expressions evaluation + +SELECT xmlpath('/value', data) FROM xmltest; +SELECT xmlpath(NULL, NULL) IS NULL FROM xmltest; +SELECT xmlpath('', '<!-- error -->'); +SELECT xmlpath('//text()', '<local:data xmlns:local="http://127.0.0.1"><local:piece id="1">number one</local:piece><local:piece id="2" /></local:data>'); +SELECT xmlpath('//loc:piece/@id', '<local:data xmlns:local="http://127.0.0.1"><local:piece id="1">number one</local:piece><local:piece id="2" /></local:data>', ARRAY[ARRAY['loc'], ARRAY['http://127.0.0.1']]); |