summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <bar@mysql.com>2006-05-03 09:08:12 +0500
committerunknown <bar@mysql.com>2006-05-03 09:08:12 +0500
commit20256d8a5687d15655c3d9073a78e8dc456cca91 (patch)
tree4dbcb10824e0a225b3338e2e4557b62576881887
parentc7a5f503420c56522ccc63fdcac80177e00dabb1 (diff)
parent1a3cb50c24f8af7124823ddd8d85e97632182cb2 (diff)
downloadmariadb-git-20256d8a5687d15655c3d9073a78e8dc456cca91.tar.gz
Merge mysql.com:/usr/home/bar/mysql-5.1-new
into mysql.com:/usr/home/bar/mysql-5.1-new.b18170 mysql-test/r/xml.result: Auto merged mysql-test/t/xml.test: Auto merged sql/item_xmlfunc.cc: Auto merged
-rw-r--r--mysql-test/r/xml.result9
-rw-r--r--mysql-test/t/xml.test8
-rw-r--r--sql/item_xmlfunc.cc26
3 files changed, 42 insertions, 1 deletions
diff --git a/mysql-test/r/xml.result b/mysql-test/r/xml.result
index 61dd1390a6a..06dc2f3d78a 100644
--- a/mysql-test/r/xml.result
+++ b/mysql-test/r/xml.result
@@ -665,3 +665,12 @@ CALL p2();
EXTRACTVALUE(p,'/Ñ/r')
A
DROP PROCEDURE p2;
+select extractValue('<ns:element xmlns:ns="myns"/>','count(ns:element)');
+extractValue('<ns:element xmlns:ns="myns"/>','count(ns:element)')
+1
+select extractValue('<ns:element xmlns:ns="myns">a</ns:element>','/ns:element');
+extractValue('<ns:element xmlns:ns="myns">a</ns:element>','/ns:element')
+a
+select extractValue('<ns:element xmlns:ns="myns">a</ns:element>','/ns:element/@xmlns:ns');
+extractValue('<ns:element xmlns:ns="myns">a</ns:element>','/ns:element/@xmlns:ns')
+myns
diff --git a/mysql-test/t/xml.test b/mysql-test/t/xml.test
index 8a12dbca51d..65d0a40291f 100644
--- a/mysql-test/t/xml.test
+++ b/mysql-test/t/xml.test
@@ -335,3 +335,11 @@ END//
DELIMITER ;//
CALL p2();
DROP PROCEDURE p2;
+
+#
+# Bug#18170: XML: ExtractValue():
+# XPath expression can't use QNames (colon in names)
+#
+select extractValue('<ns:element xmlns:ns="myns"/>','count(ns:element)');
+select extractValue('<ns:element xmlns:ns="myns">a</ns:element>','/ns:element');
+select extractValue('<ns:element xmlns:ns="myns">a</ns:element>','/ns:element/@xmlns:ns');
diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc
index a245e3b1b33..17e8db90dc7 100644
--- a/sql/item_xmlfunc.cc
+++ b/sql/item_xmlfunc.cc
@@ -2281,6 +2281,30 @@ static int my_xpath_parse_Number(MY_XPATH *xpath)
/*
+ QName grammar can be found in a separate document
+ http://www.w3.org/TR/REC-xml-names/#NT-QName
+
+ [6] QName ::= (Prefix ':')? LocalPart
+ [7] Prefix ::= NCName
+ [8] LocalPart ::= NCName
+*/
+static int
+my_xpath_parse_QName(MY_XPATH *xpath)
+{
+ const char *beg;
+ if (!my_xpath_parse_term(xpath, MY_XPATH_LEX_IDENT))
+ return 0;
+ beg= xpath->prevtok.beg;
+ if (!my_xpath_parse_term(xpath, MY_XPATH_LEX_COLON))
+ return 1; /* Non qualified name */
+ if (!my_xpath_parse_term(xpath, MY_XPATH_LEX_IDENT))
+ return 0;
+ xpath->prevtok.beg= beg;
+ return 1;
+}
+
+
+/*
Scan Variable reference
SYNOPSYS
@@ -2313,7 +2337,7 @@ my_xpath_parse_VariableReference(MY_XPATH *xpath)
static int
my_xpath_parse_NodeTest_QName(MY_XPATH *xpath)
{
- if (!my_xpath_parse_term(xpath, MY_XPATH_LEX_IDENT))
+ if (!my_xpath_parse_QName(xpath))
return 0;
DBUG_ASSERT(xpath->context);
uint len= xpath->prevtok.end - xpath->prevtok.beg;