Bug #69735 Wasted work in method my_xml_error_pos()
| Submitted: | 13 Jul 2013 2:21 | Modified: | 21 Nov 2013 14:11 |
|---|---|---|---|
| Reporter: | Po-Chun Chang | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server: XML functions | Severity: | S5 (Performance) |
| Version: | 5.6, 5.7 | OS: | Any |
| Assigned to: | CPU Architecture: | Any | |
| Tags: | patch, performance | ||
[13 Jul 2013 2:22]
Po-Chun Chang
Suggested patch (*) I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.
Contribution: patch.diff (text/plain), 400 bytes.
[13 Jul 2013 7:32]
Shane Bester
thank you for another optimization report!
[21 Nov 2013 14:11]
Jon Stephens
Thank you for your bug report. This issue has been committed to our source repository of that product and will be incorporated into the next release.
If necessary, you can access the source repository and build the latest available version, including the bug fix. More information about accessing the source trees is available at
http://dev.mysql.com/doc/en/installing-source.html
[21 Nov 2013 14:11]
Jon Stephens
This is fixed in MySQL 5.7.3. Thanks for the contribution.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.058 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
Description: The problem appears in version 5.6 and in the revision 5216 in version 5.7. I attached a two-line patch that fixes it. In method my_xml_error_pos() in xml.c, the loop in line 553 keeps overriding "beg" with "s" when 's[0]' equals '\n'. Therefore, only the last written value is visible out of the loop and all the other writes and iterations are not necessary. The patch iterates from the end of "s" and breaks the first time when "beg" is set. How to repeat: Once method my_xml_error_pos() is executed. Suggested fix: === modified file 'strings/xml.c' --- strings/xml.c 2012-12-14 11:16:06 +0000 +++ strings/xml.c 2013-07-13 02:21:08 +0000 @@ -550,10 +550,12 @@ { const char *beg=p->beg; const char *s; - for ( s=p->beg ; s<p->cur; s++) + for ( s=p->cur - 1 ; s>p->beg - 1; s--) { - if (s[0] == '\n') + if (s[0] == '\n') { beg=s; + break; + } } return (size_t) (p->cur-beg); }