From 32ede45dd416e3ddbcf26ed0704cd86886f5bbd4 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 14 Sep 2006 11:47:19 +0500 Subject: 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). --- mysql-test/r/xml.result | 28 +++++++++++++++++++++++++++- mysql-test/t/xml.test | 16 ++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) (limited to 'mysql-test') diff --git a/mysql-test/r/xml.result b/mysql-test/r/xml.result index 780be01d7ce..efe7d14095d 100644 --- a/mysql-test/r/xml.result +++ b/mysql-test/r/xml.result @@ -570,7 +570,7 @@ select extractvalue('aB','a|/b'); extractvalue('aB','a|/b') a select extractvalue('A','/'); -ERROR HY000: XPATH syntax error: '' +ERROR HY000: XPATH error: comparison of two nodesets is not supported: '' select extractvalue('bb!','//b!'); ERROR HY000: XPATH syntax error: '!' select extractvalue('ABC','/a/descendant::*'); @@ -710,3 +710,29 @@ Data select extractValue('DataOtherdata','/foo/something'); extractValue('DataOtherdata','/foo/something') Otherdata +select extractValue('<01>10:39:15<02>140','/zot/tim0/02'); +ERROR HY000: XPATH syntax error: '02' +select extractValue('<01>10:39:15<02>140','//*'); +extractValue('<01>10:39:15<02>140','//*') +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('test','//*'); +extractValue('test','//*') +test diff --git a/mysql-test/t/xml.test b/mysql-test/t/xml.test index d510a61f04d..3347573b4b7 100644 --- a/mysql-test/t/xml.test +++ b/mysql-test/t/xml.test @@ -360,3 +360,19 @@ select extractValue('a','/ns:element/@x # select extractValue('DataOtherdata','/foo/foo.bar'); select extractValue('DataOtherdata','/foo/something'); + +# +# Bug#20854 XML functions: wrong result in ExtractValue +# +--error 1105 +select extractValue('<01>10:39:15<02>140','/zot/tim0/02'); +select extractValue('<01>10:39:15<02>140','//*'); +# dot and dash are bad identtifier start character +select extractValue('<.>test','//*'); +select extractValue('<->test','//*'); +# semicolon is good identifier start character +select extractValue('<:>test','//*'); +# underscore is good identifier start character +select extractValue('<_>test','//*'); +# dot, dash, underscore and semicolon are good identifier middle characters +select extractValue('test','//*'); -- cgit v1.2.1