mirror of
https://github.com/MariaDB/server.git
synced 2025-12-24 11:21:21 +03:00
Bug#20854 XML functions: wrong result in ExtractValue
mysql-test/r/xml.result:
- Adding test case
- Fixing error message
mysql-test/t/xml.test:
Adding test case
sql/item_xmlfunc.cc:
For grammar rules with loops like:
AdditiveExpr ::= MultiplicativeExpr ('+' MultiplicativeExpr)*
If we scanned scanned '+' and then met an error when parsing
MultiplicativeExpr, then we should fully stop parsing - without
trying to apply any other rules.
Fix: add "error" member into MY_XPATH structure,
and make my_xpath_parse_term() never return success
as soon as error set.
strings/xml.c:
Adding my_xml_ctype map for flags, indicating
whether a character is a space character, is a
valid identifier start character, is a valid
identifier body character. Using this map to
properly scan identifiers. Also, using this map
to scan spaces faster (instead of strchr).
This commit is contained in:
@@ -570,7 +570,7 @@ select extractvalue('<a>a<b>B</b></a>','a|/b');
|
||||
extractvalue('<a>a<b>B</b></a>','a|/b')
|
||||
a
|
||||
select extractvalue('<a>A</a>','/<a>');
|
||||
ERROR HY000: XPATH syntax error: '<a>'
|
||||
ERROR HY000: XPATH error: comparison of two nodesets is not supported: '<a>'
|
||||
select extractvalue('<a><b>b</b><b!>b!</b!></a>','//b!');
|
||||
ERROR HY000: XPATH syntax error: '!'
|
||||
select extractvalue('<a>A<b>B<c>C</c></b></a>','/a/descendant::*');
|
||||
@@ -710,3 +710,29 @@ Data
|
||||
select extractValue('<foo><foo.bar>Data</foo.bar><something>Otherdata</something></foo>','/foo/something');
|
||||
extractValue('<foo><foo.bar>Data</foo.bar><something>Otherdata</something></foo>','/foo/something')
|
||||
Otherdata
|
||||
select extractValue('<zot><tim0><01>10:39:15</01><02>140</02></tim0></zot>','/zot/tim0/02');
|
||||
ERROR HY000: XPATH syntax error: '02'
|
||||
select extractValue('<zot><tim0><01>10:39:15</01><02>140</02></tim0></zot>','//*');
|
||||
extractValue('<zot><tim0><01>10:39:15</01><02>140</02></tim0></zot>','//*')
|
||||
NULL
|
||||
Warnings:
|
||||
Warning 1512 Incorrect XML value: 'parse error at line 1 pos 13: unknown token unexpected (ident or '/' wanted)'
|
||||
select extractValue('<.>test</.>','//*');
|
||||
extractValue('<.>test</.>','//*')
|
||||
NULL
|
||||
Warnings:
|
||||
Warning 1512 Incorrect XML value: 'parse error at line 1 pos 2: unknown token unexpected (ident or '/' wanted)'
|
||||
select extractValue('<->test</->','//*');
|
||||
extractValue('<->test</->','//*')
|
||||
NULL
|
||||
Warnings:
|
||||
Warning 1512 Incorrect XML value: 'parse error at line 1 pos 2: unknown token unexpected (ident or '/' wanted)'
|
||||
select extractValue('<:>test</:>','//*');
|
||||
extractValue('<:>test</:>','//*')
|
||||
test
|
||||
select extractValue('<_>test</_>','//*');
|
||||
extractValue('<_>test</_>','//*')
|
||||
test
|
||||
select extractValue('<x.-_:>test</x.-_:>','//*');
|
||||
extractValue('<x.-_:>test</x.-_:>','//*')
|
||||
test
|
||||
|
||||
Reference in New Issue
Block a user