diff options
author | unknown <bar@mysql.com> | 2006-03-01 13:16:12 +0400 |
---|---|---|
committer | unknown <bar@mysql.com> | 2006-03-01 13:16:12 +0400 |
commit | 3f480fcb9f726f65925526045e036b16ecc2d8fa (patch) | |
tree | cf0ebef280a9b8482ee2914315f405ed0f8df4db /sql/item_xmlfunc.cc | |
parent | 7f7c624656840767e601b9f156cfeae109ca5b37 (diff) | |
download | mariadb-git-3f480fcb9f726f65925526045e036b16ecc2d8fa.tar.gz |
Bug#16315 XML: extractvalue() handles self badly
xml.result, xml.test:
Adding test case.
item_xmlfunc.cc:
Adding a special function to handle "self" axis.
Previously "child" and "self" were handled the same.
sql/item_xmlfunc.cc:
Bug#16315 XML: extractvalue() handles self badly
Adding a special function to handle "self" axis.
Previously "child" and "self" were handled the same.
mysql-test/t/xml.test:
Adding test case.
mysql-test/r/xml.result:
Adding test case.
Diffstat (limited to 'sql/item_xmlfunc.cc')
-rw-r--r-- | sql/item_xmlfunc.cc | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc index aad9e12f6c5..8fc3a2b170c 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); } |