List:Commits« Previous MessageNext Message »
From:bar Date:April 7 2006 9:08am
Subject:bk commit into 5.1 tree (bar:1.2298) BUG#16319
View as plain text  
Below is the list of changes that have just been committed into a local
5.1 repository of bar. When bar does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2298 06/04/07 14:07:56 bar@stripped +3 -0
  Bug#16319: XML: extractvalue() returns syntax errors for some functions

  sql/item_xmlfunc.cc
    1.13 06/04/07 14:07:45 bar@stripped +17 -1
    Adding support for missing XPath function string-length().
    Fixing function lookup to allow functions with one optional arguments
    (i.e. with 0 or 1 arguments)

  mysql-test/t/xml.test
    1.11 06/04/07 14:07:45 bar@stripped +14 -0
    Adding test case

  mysql-test/r/xml.result
    1.11 06/04/07 14:07:44 bar@stripped +24 -0
    Adding test case

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	bar
# Host:	bar.intranet.mysql.r18.ru
# Root:	/usr/home/bar/mysql-5.1-new.b16319

--- 1.10/mysql-test/r/xml.result	2006-03-20 14:53:12 +04:00
+++ 1.11/mysql-test/r/xml.result	2006-04-07 14:07:44 +05:00
@@ -468,6 +468,30 @@ extractValue(@xml, '/a/@b[substring(.,2,
 select extractValue(@xml, '/a/@b[substring(.,2,1)="2"]');
 extractValue(@xml, '/a/@b[substring(.,2,1)="2"]')
 12 22
+SET @xml='<a><b>b1</b><b>b2</b></a>';
+SELECT extractValue(@xml, '/a/b[string-length("x")=1]');
+extractValue(@xml, '/a/b[string-length("x")=1]')
+b1 b2
+SELECT extractValue(@xml, '/a/b[string-length("xx")=2]');
+extractValue(@xml, '/a/b[string-length("xx")=2]')
+b1 b2
+SELECT extractValue(@xml, '/a/b[string-length("xxx")=2]');
+extractValue(@xml, '/a/b[string-length("xxx")=2]')
+
+SELECT extractValue(@xml, '/a/b[string-length("x")]');
+extractValue(@xml, '/a/b[string-length("x")]')
+b1
+SELECT extractValue(@xml, '/a/b[string-length("xx")]');
+extractValue(@xml, '/a/b[string-length("xx")]')
+b2
+SELECT extractValue(@xml, '/a/b[string-length()]');
+extractValue(@xml, '/a/b[string-length()]')
+b2
+SELECT extractValue(@xml, 'string-length()');
+ERROR HY000: XPATH syntax error: ''
+SELECT extractValue(@xml, 'string-length("x")');
+extractValue(@xml, 'string-length("x")')
+1
 SET @xml='<a b="b11" b="b12" b="b21" b="22"/>';
 select extractValue(@xml,'/a/@b');
 extractValue(@xml,'/a/@b')

--- 1.10/mysql-test/t/xml.test	2006-03-20 14:53:06 +04:00
+++ 1.11/mysql-test/t/xml.test	2006-04-07 14:07:45 +05:00
@@ -192,6 +192,20 @@ select extractValue(@xml, '/a/@b[substri
 select extractValue(@xml, '/a/@b[substring(.,2,1)="1"]');
 select extractValue(@xml, '/a/@b[substring(.,2,1)="2"]');
 
+#
+# Bug#16319: XML: extractvalue() returns syntax errors for some functions
+#
+SET @xml='<a><b>b1</b><b>b2</b></a>';
+SELECT extractValue(@xml, '/a/b[string-length("x")=1]');
+SELECT extractValue(@xml, '/a/b[string-length("xx")=2]');
+SELECT extractValue(@xml, '/a/b[string-length("xxx")=2]');
+SELECT extractValue(@xml, '/a/b[string-length("x")]');
+SELECT extractValue(@xml, '/a/b[string-length("xx")]');
+SELECT extractValue(@xml, '/a/b[string-length()]');
+--error 1105
+SELECT extractValue(@xml, 'string-length()');
+SELECT extractValue(@xml, 'string-length("x")');
+
 SET @xml='<a b="b11" b="b12" b="b21" b="22"/>';
 select extractValue(@xml,'/a/@b');
 select extractValue(@xml,'/a/@b[contains(.,"1")]');

--- 1.12/sql/item_xmlfunc.cc	2006-03-29 16:27:30 +05:00
+++ 1.13/sql/item_xmlfunc.cc	2006-04-07 14:07:45 +05:00
@@ -1133,6 +1133,13 @@ static Item *create_func_number(MY_XPATH
 }
 
 
+static Item *create_func_string_length(MY_XPATH *xpath, Item **args, uint nargs)
+{
+  Item *arg= nargs ? args[0] : xpath->context;
+  return arg ? new Item_func_char_length(arg) : 0;
+}
+
+
 static Item *create_func_round(MY_XPATH *xpath, Item **args, uint nargs)
 {
   return new Item_func_round(args[0], new Item_int((char*)"0",0,1),0);
@@ -1243,9 +1250,11 @@ static MY_XPATH_FUNC my_func_names[] =
   {"substring"        , 9  ,  2 , 3  , create_func_substr},
   {"translate"        , 9  ,  3 , 3  , 0},
 
+
   {"local-name"       , 10 ,  0 , 1  , 0},
   {"starts-with"      , 11 ,  2 , 2  , 0},
   {"namespace-uri"    , 13 ,  0 , 1  , 0},
+  {"string-length"    , 13 ,  0 , 1  , create_func_string_length},
   {"substring-after"  , 15 ,  2 , 2  , 0},
   {"normalize-space"  , 15 ,  0 , 1  , 0},
   {"substring-before" , 16 ,  2 , 2  , 0},
@@ -1849,7 +1858,12 @@ static int my_xpath_parse_FunctionCall(M
   for (nargs= 0 ; nargs < func->maxargs; )
   {
     if (!my_xpath_parse_Expr(xpath))
-     return 0;
+    {
+      if (nargs < func->minargs)
+        return 0;
+      else
+        goto right_paren;
+    }
     args[nargs++]= xpath->item;
     if (!my_xpath_parse_term(xpath, MY_XPATH_LEX_COMMA))
     {
@@ -1859,6 +1873,8 @@ static int my_xpath_parse_FunctionCall(M
         break;
     }
   }
+
+right_paren:
   if (!my_xpath_parse_term(xpath, MY_XPATH_LEX_RP))
     return 0;
 
Thread
bk commit into 5.1 tree (bar:1.2298) BUG#16319bar7 Apr