Commit 1dc87feb authored by unknown's avatar unknown

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.


sql/item_xmlfunc.cc:
  Bug #18171 XML: ExtractValue: the XPath position() function crashes the server!
  Disallowing use of position() and last() without context.
mysql-test/t/xml.test:
  Adding test.
mysql-test/r/xml.result:
  Adding test.
parent 4ac5afa3
......@@ -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")]');
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")]');
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>' 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)
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)
{
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