Commit e983bc74 authored by bar@mysql.com's avatar bar@mysql.com

xml.result, xml.test:

  Adding test.
item_xmlfunc.cc:
  Bug #18171 XML: ExtractValue: the XPath position() function crashes the server!
  Disallowing use of position() and last() without context.
parent ecf41eea
...@@ -609,3 +609,7 @@ extractvalue('<a>Jack</a>','/a[contains(../a,"j")]' collate latin1_bin) ...@@ -609,3 +609,7 @@ extractvalue('<a>Jack</a>','/a[contains(../a,"j")]' collate latin1_bin)
select extractvalue('<a>Jack</a>' collate latin1_bin,'/a[contains(../a,"j")]'); select extractvalue('<a>Jack</a>' collate latin1_bin,'/a[contains(../a,"j")]');
extractvalue('<a>Jack</a>' collate latin1_bin,'/a[contains(../a,"j")]') extractvalue('<a>Jack</a>' collate latin1_bin,'/a[contains(../a,"j")]')
select extractValue('<e>1</e>','position()');
ERROR HY000: XPATH syntax error: ''
select extractValue('<e>1</e>','last()');
ERROR HY000: XPATH syntax error: ''
...@@ -277,3 +277,12 @@ select extractvalue('<a>Jack</a>','/a[contains(../a,"J")]'); ...@@ -277,3 +277,12 @@ select extractvalue('<a>Jack</a>','/a[contains(../a,"J")]');
select extractvalue('<a>Jack</a>','/a[contains(../a,"j")]'); select extractvalue('<a>Jack</a>','/a[contains(../a,"j")]');
select extractvalue('<a>Jack</a>','/a[contains(../a,"j")]' collate latin1_bin); select extractvalue('<a>Jack</a>','/a[contains(../a,"j")]' collate latin1_bin);
select extractvalue('<a>Jack</a>' collate latin1_bin,'/a[contains(../a,"j")]'); select extractvalue('<a>Jack</a>' collate latin1_bin,'/a[contains(../a,"j")]');
#
# Bug #18171 XML: ExtractValue: the XPath position()
# function crashes the server!
#
--error 1105
select extractValue('<e>1</e>','position()');
--error 1105
select extractValue('<e>1</e>','last()');
...@@ -1141,13 +1141,15 @@ static Item *create_func_round(MY_XPATH *xpath, Item **args, uint nargs) ...@@ -1141,13 +1141,15 @@ static Item *create_func_round(MY_XPATH *xpath, Item **args, uint nargs)
static Item *create_func_last(MY_XPATH *xpath, Item **args, uint nargs) static Item *create_func_last(MY_XPATH *xpath, Item **args, uint nargs)
{ {
return new Item_func_xpath_count(xpath->context, xpath->pxml); return xpath->context ?
new Item_func_xpath_count(xpath->context, xpath->pxml) : NULL;
} }
static Item *create_func_position(MY_XPATH *xpath, Item **args, uint nargs) static Item *create_func_position(MY_XPATH *xpath, Item **args, uint nargs)
{ {
return new Item_func_xpath_position(xpath->context, xpath->pxml); return xpath->context ?
new Item_func_xpath_position(xpath->context, xpath->pxml) : NULL;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment