summaryrefslogtreecommitdiff
path: root/mysql-test
diff options
context:
space:
mode:
Diffstat (limited to 'mysql-test')
-rw-r--r--mysql-test/r/xml.result32
-rw-r--r--mysql-test/t/xml.test13
2 files changed, 43 insertions, 2 deletions
diff --git a/mysql-test/r/xml.result b/mysql-test/r/xml.result
index 06dc2f3d78a..5ff210106dd 100644
--- a/mysql-test/r/xml.result
+++ b/mysql-test/r/xml.result
@@ -132,7 +132,7 @@ xb1 xc1
SELECT extractValue(@xml,'/a//@x[2]');
extractValue(@xml,'/a//@x[2]')
xb2 xc2
-SET @xml='<a><b>b1</b><b>b2</b><c><b>c1b1</b><b>c1b2</b></c><c><b>c2b1</c></b>/a>';
+SET @xml='<a><b>b1</b><b>b2</b><c><b>c1b1</b><b>c1b2</b></c><c><b>c2b1</c></b></a>';
SELECT extractValue(@xml,'//b[1]');
extractValue(@xml,'//b[1]')
b1 c1b1 c2b1
@@ -636,6 +636,36 @@ extractvalue('<a>Jack</a>' collate latin1_bin,'/a[contains(../a,"j")]')
select ExtractValue('<tag1><![CDATA[test]]></tag1>','/tag1');
ExtractValue('<tag1><![CDATA[test]]></tag1>','/tag1')
test
+select extractValue('<a>a','/a');
+extractValue('<a>a','/a')
+NULL
+Warnings:
+Warning 1504 Incorrect XML value: 'parse error at line 1 pos 5: unexpected END-OF-INPUT'
+select extractValue('<a>a<','/a');
+extractValue('<a>a<','/a')
+NULL
+Warnings:
+Warning 1504 Incorrect XML value: 'parse error at line 1 pos 6: END-OF-INPUT unexpected (ident or '/' wanted)'
+select extractValue('<a>a</','/a');
+extractValue('<a>a</','/a')
+NULL
+Warnings:
+Warning 1504 Incorrect XML value: 'parse error at line 1 pos 7: END-OF-INPUT unexpected (ident wanted)'
+select extractValue('<a>a</a','/a');
+extractValue('<a>a</a','/a')
+NULL
+Warnings:
+Warning 1504 Incorrect XML value: 'parse error at line 1 pos 8: END-OF-INPUT unexpected ('>' wanted)'
+select extractValue('<a>a</a></b>','/a');
+extractValue('<a>a</a></b>','/a')
+NULL
+Warnings:
+Warning 1504 Incorrect XML value: 'parse error at line 1 pos 12: '</b>' unexpected (END-OF-INPUT wanted)'
+select extractValue('<a b=>a</a>','/a');
+extractValue('<a b=>a</a>','/a')
+NULL
+Warnings:
+Warning 1504 Incorrect XML value: 'parse error at line 1 pos 7: '>' unexpected (ident or string wanted)'
select extractValue('<e>1</e>','position()');
ERROR HY000: XPATH syntax error: ''
select extractValue('<e>1</e>','last()');
diff --git a/mysql-test/t/xml.test b/mysql-test/t/xml.test
index 65d0a40291f..c20c4cbccc1 100644
--- a/mysql-test/t/xml.test
+++ b/mysql-test/t/xml.test
@@ -53,7 +53,7 @@ SELECT extractValue(@xml,'/a//@x');
SELECT extractValue(@xml,'/a//@x[1]');
SELECT extractValue(@xml,'/a//@x[2]');
-SET @xml='<a><b>b1</b><b>b2</b><c><b>c1b1</b><b>c1b2</b></c><c><b>c2b1</c></b>/a>';
+SET @xml='<a><b>b1</b><b>b2</b><c><b>c1b1</b><b>c1b2</b></c><c><b>c2b1</c></b></a>';
SELECT extractValue(@xml,'//b[1]');
SELECT extractValue(@xml,'/descendant::b[1]');
@@ -299,6 +299,17 @@ select extractvalue('<a>Jack</a>' collate latin1_bin,'/a[contains(../a,"j")]');
select ExtractValue('<tag1><![CDATA[test]]></tag1>','/tag1');
#
+# Bug#18201: XML: ExtractValue works even if the xml fragment
+# is not well-formed xml
+#
+select extractValue('<a>a','/a');
+select extractValue('<a>a<','/a');
+select extractValue('<a>a</','/a');
+select extractValue('<a>a</a','/a');
+select extractValue('<a>a</a></b>','/a');
+select extractValue('<a b=>a</a>','/a');
+
+#
# Bug #18171 XML: ExtractValue: the XPath position()
# function crashes the server!
#