summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <bar@mysql.com>2006-03-02 10:42:08 +0400
committerunknown <bar@mysql.com>2006-03-02 10:42:08 +0400
commit526d28f36a8e5cabbec495d5745230faa0471011 (patch)
tree870c8c101fe7f45878a5679e849ae600cb287094
parent605c82d2a8502d4114a0ab1768ccf894903699e6 (diff)
parent3f480fcb9f726f65925526045e036b16ecc2d8fa (diff)
downloadmariadb-git-526d28f36a8e5cabbec495d5745230faa0471011.tar.gz
Merge abarkov@bk-internal.mysql.com:/home/bk/mysql-5.1-new
into mysql.com:/usr/home/bar/mysql-5.1-new.16315 sql/item_xmlfunc.cc: Auto merged mysql-test/r/xml.result: After merge fix mysql-test/t/xml.test: After merge fix
-rw-r--r--mysql-test/r/xml.result12
-rw-r--r--mysql-test/t/xml.test6
-rw-r--r--sql/item_xmlfunc.cc29
3 files changed, 47 insertions, 0 deletions
diff --git a/mysql-test/r/xml.result b/mysql-test/r/xml.result
index b5ed4ef8b5a..0b75b50f754 100644
--- a/mysql-test/r/xml.result
+++ b/mysql-test/r/xml.result
@@ -65,6 +65,9 @@ c1
SELECT extractValue(@xml,'/a/child::*');
extractValue(@xml,'/a/child::*')
b1 b2
+SELECT extractValue(@xml,'/a/self::*');
+extractValue(@xml,'/a/self::*')
+a1 a2
SELECT extractValue(@xml,'/a/descendant::*');
extractValue(@xml,'/a/descendant::*')
b1 c1 b2
@@ -546,6 +549,15 @@ select extractvalue('<a>A</a>','/<a>');
ERROR HY000: XPATH syntax error: '>'
select extractvalue('<a><b>b</b><b!>b!</b!></a>','//b!');
ERROR HY000: XPATH syntax error: '!'
+select extractvalue('<a>A<b>B<c>C</c></b></a>','/a/descendant::*');
+extractvalue('<a>A<b>B<c>C</c></b></a>','/a/descendant::*')
+B C
+select extractvalue('<a>A<b>B<c>C</c></b></a>','/a/self::*');
+extractvalue('<a>A<b>B<c>C</c></b></a>','/a/self::*')
+A
+select extractvalue('<a>A<b>B<c>C</c></b></a>','/a/descendant-or-self::*');
+extractvalue('<a>A<b>B<c>C</c></b></a>','/a/descendant-or-self::*')
+A B C
select extractvalue('<A_B>A</A_B>','/A_B');
extractvalue('<A_B>A</A_B>','/A_B')
A
diff --git a/mysql-test/t/xml.test b/mysql-test/t/xml.test
index fa7599df898..6a91d785d4e 100644
--- a/mysql-test/t/xml.test
+++ b/mysql-test/t/xml.test
@@ -23,6 +23,7 @@ SELECT extractValue(@xml,'/*/*');
SELECT extractValue(@xml,'/*/*/*');
SELECT extractValue(@xml,'/a/child::*');
+SELECT extractValue(@xml,'/a/self::*');
SELECT extractValue(@xml,'/a/descendant::*');
SELECT extractValue(@xml,'/a/descendant-or-self::*');
SELECT extractValue(@xml,'/a/attribute::*');
@@ -245,6 +246,11 @@ select extractvalue('<a>A</a>','/<a>');
select extractvalue('<a><b>b</b><b!>b!</b!></a>','//b!');
#
+# Bug #16315 XML: extractvalue() handles self badly
+#
+select extractvalue('<a>A<b>B<c>C</c></b></a>','/a/descendant::*');
+select extractvalue('<a>A<b>B<c>C</c></b></a>','/a/self::*');
+select extractvalue('<a>A<b>B<c>C</c></b></a>','/a/descendant-or-self::*');
# Bug #16320 XML: extractvalue() won't accept names containing underscores
#
select extractvalue('<A_B>A</A_B>','/A_B');
diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc
index 61f7579fa22..26c2e84f8dd 100644
--- a/sql/item_xmlfunc.cc
+++ b/sql/item_xmlfunc.cc
@@ -252,6 +252,18 @@ public:
};
+/* Returns self */
+class Item_nodeset_func_selfbyname: public Item_nodeset_func_axisbyname
+{
+public:
+ Item_nodeset_func_selfbyname(Item *a, const char *n_arg, uint l_arg,
+ String *pxml):
+ Item_nodeset_func_axisbyname(a, n_arg, l_arg, pxml) {}
+ const char *func_name() const { return "xpath_selfbyname"; }
+ String *val_nodeset(String *nodeset);
+};
+
+
/* Returns children */
class Item_nodeset_func_childbyname: public Item_nodeset_func_axisbyname
{
@@ -572,6 +584,20 @@ String * Item_nodeset_func_union::val_nodeset(String *nodeset)
}
+String *Item_nodeset_func_selfbyname::val_nodeset(String *nodeset)
+{
+ prepare(nodeset);
+ for (MY_XPATH_FLT *flt= fltbeg; flt < fltend; flt++)
+ {
+ uint pos= 0;
+ MY_XML_NODE *self= &nodebeg[flt->num];
+ if (validname(self))
+ ((XPathFilter*)nodeset)->append_element(flt->num,pos++);
+ }
+ return nodeset;
+}
+
+
String *Item_nodeset_func_childbyname::val_nodeset(String *nodeset)
{
prepare(nodeset);
@@ -945,6 +971,9 @@ static Item* nametestfunc(MY_XPATH *xpath,
case MY_XPATH_AXIS_ATTRIBUTE:
res= new Item_nodeset_func_attributebyname(arg, beg, len, xpath->pxml);
break;
+ case MY_XPATH_AXIS_SELF:
+ res= new Item_nodeset_func_selfbyname(arg, beg, len, xpath->pxml);
+ break;
default:
res= new Item_nodeset_func_childbyname(arg, beg, len, xpath->pxml);
}