diff options
author | unknown <bar@mysql.com> | 2006-04-14 13:34:18 +0500 |
---|---|---|
committer | unknown <bar@mysql.com> | 2006-04-14 13:34:18 +0500 |
commit | 9faa29707451a7916ad7e9fd96e845f05d63c651 (patch) | |
tree | 19c9c2084d444ae35cade9c9b8ebe572f022d985 | |
parent | c6f311a0c1139af34c4b901def7c433d2e7b43ae (diff) | |
parent | e84041f174684beda03b25acec82b93d04445e41 (diff) | |
download | mariadb-git-9faa29707451a7916ad7e9fd96e845f05d63c651.tar.gz |
Merge mysql.com:/usr/home/bar/mysql-5.1-new
into mysql.com:/usr/home/bar/mysql-5.1-new.b16319
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.result | 24 | ||||
-rw-r--r-- | mysql-test/t/xml.test | 14 | ||||
-rw-r--r-- | sql/item_xmlfunc.cc | 18 |
3 files changed, 55 insertions, 1 deletions
diff --git a/mysql-test/r/xml.result b/mysql-test/r/xml.result index 7e44673dd78..61dd1390a6a 100644 --- a/mysql-test/r/xml.result +++ b/mysql-test/r/xml.result @@ -468,6 +468,30 @@ extractValue(@xml, '/a/@b[substring(.,2,1)="1"]') 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') diff --git a/mysql-test/t/xml.test b/mysql-test/t/xml.test index 8ed623883b6..8a12dbca51d 100644 --- a/mysql-test/t/xml.test +++ b/mysql-test/t/xml.test @@ -192,6 +192,20 @@ select extractValue(@xml, '/a/@b[substring(.,1,1)="2"]'); 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")]'); diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc index 71900c26c2d..6e5941cccf9 100644 --- a/sql/item_xmlfunc.cc +++ b/sql/item_xmlfunc.cc @@ -1133,6 +1133,13 @@ static Item *create_func_number(MY_XPATH *xpath, Item **args, uint nargs) } +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}, @@ -1837,7 +1846,12 @@ static int my_xpath_parse_FunctionCall(MY_XPATH *xpath) 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)) { @@ -1847,6 +1861,8 @@ static int my_xpath_parse_FunctionCall(MY_XPATH *xpath) break; } } + +right_paren: if (!my_xpath_parse_term(xpath, MY_XPATH_LEX_RP)) return 0; |