summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorPeter Eisentraut2007-05-21 17:10:29 +0000
committerPeter Eisentraut2007-05-21 17:10:29 +0000
commit3963574d13383b4f377ab054e47e4af20cb75e7d (patch)
treec938be981d3511412f46d640f3f6226796cb8589 /src/test
parent0c644d2c3d50a6a9f8b3821d1fe6b0f0753804b1 (diff)
XPath fixes:
- Function renamed to "xpath". - Function is now strict, per discussion. - Return empty array in case when XPath expression detects nothing (previously, NULL was returned in such case), per discussion. - (bugfix) Work with fragments with prologue: select xpath('/a', '<?xml version="1.0"?><a /><b />'); // now XML datum is always wrapped with dummy <x>...</x>, XML prologue simply goes away (if any). - Some cleanup. Nikolay Samokhvalov Some code cleanup and documentation work by myself.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/expected/xml.out24
-rw-r--r--src/test/regress/expected/xml_1.out24
-rw-r--r--src/test/regress/sql/xml.sql12
3 files changed, 30 insertions, 30 deletions
diff --git a/src/test/regress/expected/xml.out b/src/test/regress/expected/xml.out
index 20520d97606..cec9ea29442 100644
--- a/src/test/regress/expected/xml.out
+++ b/src/test/regress/expected/xml.out
@@ -402,37 +402,37 @@ SELECT table_name, view_definition FROM information_schema.views
(9 rows)
-- Text XPath expressions evaluation
-SELECT xmlpath('/value', data) FROM xmltest;
- xmlpath
+SELECT xpath('/value', data) FROM xmltest;
+ xpath
----------------------
{<value>one</value>}
{<value>two</value>}
(2 rows)
-SELECT xmlpath(NULL, NULL) IS NULL FROM xmltest;
+SELECT xpath(NULL, NULL) IS NULL FROM xmltest;
?column?
----------
t
t
(2 rows)
-SELECT xmlpath('', '<!-- error -->');
+SELECT xpath('', '<!-- 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
+CONTEXT: SQL function "xpath" statement 1
+SELECT xpath('//text()', '<local:data xmlns:local="http://127.0.0.1"><local:piece id="1">number one</local:piece><local:piece id="2" /></local:data>');
+ xpath
----------------
{"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
----------
+SELECT xpath('//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', 'http://127.0.0.1']]);
+ xpath
+-------
{1,2}
(1 row)
-SELECT xmlpath('//b', '<a>one <b>two</b> three <b>etc</b></a>');
- xmlpath
+SELECT xpath('//b', '<a>one <b>two</b> three <b>etc</b></a>');
+ xpath
-------------------------
{<b>two</b>,<b>etc</b>}
(1 row)
diff --git a/src/test/regress/expected/xml_1.out b/src/test/regress/expected/xml_1.out
index e922107f8d3..2bf91057705 100644
--- a/src/test/regress/expected/xml_1.out
+++ b/src/test/regress/expected/xml_1.out
@@ -326,29 +326,29 @@ SELECT table_name, view_definition FROM information_schema.views
(2 rows)
-- Text XPath expressions evaluation
-SELECT xmlpath('/value', data) FROM xmltest;
- xmlpath
----------
+SELECT xpath('/value', data) FROM xmltest;
+ xpath
+-------
(0 rows)
-SELECT xmlpath(NULL, NULL) IS NULL FROM xmltest;
-ERROR: unsupported XML feature
-DETAIL: This functionality requires libxml support.
-HINT: You need to re-compile PostgreSQL using --with-libxml.
-CONTEXT: SQL function "xmlpath" statement 1
-SELECT xmlpath('', '<!-- error -->');
+SELECT xpath(NULL, NULL) IS NULL FROM xmltest;
+ ?column?
+----------
+(0 rows)
+
+SELECT xpath('', '<!-- error -->');
ERROR: unsupported XML feature
DETAIL: This functionality requires libxml support.
HINT: You need to re-compile PostgreSQL using --with-libxml.
-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 xpath('//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: unsupported XML feature
DETAIL: This functionality requires libxml support.
HINT: You need to re-compile PostgreSQL using --with-libxml.
-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']]);
+SELECT xpath('//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', 'http://127.0.0.1']]);
ERROR: unsupported XML feature
DETAIL: This functionality requires libxml support.
HINT: You need to re-compile PostgreSQL using --with-libxml.
-SELECT xmlpath('//b', '<a>one <b>two</b> three <b>etc</b></a>');
+SELECT xpath('//b', '<a>one <b>two</b> three <b>etc</b></a>');
ERROR: unsupported XML feature
DETAIL: This functionality requires libxml support.
HINT: You need to re-compile PostgreSQL using --with-libxml.
diff --git a/src/test/regress/sql/xml.sql b/src/test/regress/sql/xml.sql
index 1658a380365..2c9db299fda 100644
--- a/src/test/regress/sql/xml.sql
+++ b/src/test/regress/sql/xml.sql
@@ -147,9 +147,9 @@ SELECT table_name, view_definition FROM information_schema.views
-- 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']]);
-SELECT xmlpath('//b', '<a>one <b>two</b> three <b>etc</b></a>');
+SELECT xpath('/value', data) FROM xmltest;
+SELECT xpath(NULL, NULL) IS NULL FROM xmltest;
+SELECT xpath('', '<!-- error -->');
+SELECT xpath('//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 xpath('//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', 'http://127.0.0.1']]);
+SELECT xpath('//b', '<a>one <b>two</b> three <b>etc</b></a>');