Bug #30690 Contrib: Missing name function in XPATH
Submitted: 29 Aug 2007 11:54 Modified: 18 Oct 2011 10:01
Reporter: admin www.mercuriusgids.nl Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: XML functions Severity:S4 (Feature request)
Version:5.2 and above OS:Any
Assigned to: Assigned Account CPU Architecture:Any
Tags: Contribution, feature, FUNCTION, name, request, XML, XPath

[29 Aug 2007 11:54] admin www.mercuriusgids.nl
Description:
This patch is for Mysql server and implements the XPATH name function. 

Versions: 5.2/6.0 falcon. 

File: item_xmlfunc.cc

How to repeat:
?

Suggested fix:
[root@web-01-02 contrib]# cat item_xmlfunc.patch
--- ./old/item_xmlfunc.cc       2007-08-26 03:14:33.000000000 +0200
+++ ./new/item_xmlfunc.cc       2007-08-26 03:15:18.000000000 +0200
@@ -19,7 +19,7 @@

 #include "mysql_priv.h"
 #include "my_xml.h"
-
+

 /*
   TODO: future development directions:
@@ -452,6 +452,28 @@
 };

+class Item_func_xpath_name :public Item_str_func
+{
+  String *pxml;
+  String tmp_value;
+public:
+  Item_func_xpath_name(Item *a, String *p)
+    :Item_str_func(a), pxml(p) {}
+  const char *func_name() const { return "xpath_name"; }
+  void fix_length_and_dec() { max_length=10; }
+  String *val_str(String *str)
+  {
+    String *res= args[0]->val_nodeset(&tmp_value);
+    if (res->length() == sizeof(MY_XPATH_FLT)){
+      MY_XML_NODE *self= &( (MY_XML_NODE*) pxml->ptr() )[( (MY_XPATH_FLT*) res->ptr() )->num ];
+      res->set ( self->beg, self->end - self->beg,collation.collation );
+      return res;
+    }
+    return 0;   
+  }
+};
+
+
 class Item_func_xpath_count :public Item_int_func
 {
   String *pxml;
@@ -1071,6 +1093,7 @@
 {
   {MY_XPATH_LEX_NODETYPE, "comment"                ,  7, 0 },
   {MY_XPATH_LEX_NODETYPE, "text"                   ,  4, 0 },
+  {MY_XPATH_LEX_NODETYPE, "name"                   ,  4, 0 },
   {MY_XPATH_LEX_NODETYPE, "processing-instruction" ,  22,0 },
   {MY_XPATH_LEX_NODETYPE, "node"                   ,  4, 0 },
   {0,NULL,0,0}
@@ -1191,6 +1214,14 @@
   return new Item_func_concat(args[0], args[1]);
 }

+static Item *create_func_name(MY_XPATH *xpath, Item **args, uint nargs)
+{
+  Item *arg = new Item_func_xpath_name(args[0], xpath->pxml);
+  return arg;
+}
+

 static Item *create_func_substr(MY_XPATH *xpath, Item **args, uint nargs)
 {
@@ -1233,7 +1264,7 @@
 {
   {"last", 4, 0, 0, create_func_last},
   {"true", 4, 0, 0, create_func_true},
-  {"name", 4, 0, 1, 0},
+  {"name", 4, 0, 1, create_func_name},
   {"lang", 4, 1, 1, 0},
   {0     , 0, 0, 0, 0}
 };
[29 Aug 2007 12:30] admin www.mercuriusgids.nl
mysqld item_xmlfunc.patch

Attachment: item_xmlfunc.patch (application/octet-stream, text), 1.92 KiB.

[30 Aug 2007 5:45] Valeriy Kravchuk
Thank you for the patch.
[31 Jul 2009 13:01] Lenz Grimmer
This patch was published on the MySQL Forge before:

http://forge.mysql.com/tools/tool.php?id=99

Need to verify if the reporter of this bug is the same as the contributor on the MySQL Forge (names differ).
[31 Jul 2009 14:09] admin www.mercuriusgids.nl
Yep, RCIS Tech and JP TS are the same user.
[2 Sep 2009 18:16] Liz Drachnik
To the Patch Contributor - 

In order for us to continue the process of reviewing your contribution to MySQL - We need
you to review and sign the Sun|MySQL contributor agreement (the "SCA")

The process is explained here: 
http://forge.mysql.com/wiki/Sun_Contributor_Agreement

Getting a signed/approved SCA on file will help us facilitate your contribution-- this
one, and others in the future.

Thank you !
[2 Oct 2009 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[3 Oct 2009 16:38] admin www.mercuriusgids.nl
I am currently in the process of sending you the --signed-- SUN SCA as requested. This patch can be used without any of my authorization. We support the opensource community too. SUN will be receiving the SCA shortly.

Thank you
[18 Oct 2011 9:50] immo bilia
Why after 3 years, the xpath name() patch is not included in stable version of MySQL 5.1 ou 5.5 ?
[18 Oct 2011 10:01] admin www.mercuriusgids.nl
I really really dont have any clue why the working patch has not been implemented yet. 

Cheers admin www.mercuriusgids.nl