Bug #41566 | Quotes within comments not correctly ignored by statement parser | ||
---|---|---|---|
Submitted: | 17 Dec 2008 20:45 | Modified: | 23 Jun 2009 13:31 |
Reporter: | Jeff Kolesky | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | Connector / J | Severity: | S3 (Non-critical) |
Version: | 5.1.6 | OS: | Any |
Assigned to: | Jess Balint | CPU Architecture: | Any |
[17 Dec 2008 20:45]
Jeff Kolesky
[12 Feb 2009 14:55]
Tonci Grgin
Hi Jeff and thanks for your report. I am not able to repeat this behavior using latest c/J sources and MySQL server 5.1.30, although same code is there. Would you mind testing with latest c/J snapshot and, if it fails, attaching complete test case.
[12 Feb 2009 20:35]
Jess Balint
fix + test
Attachment: bug41566.diff (text/x-diff), 1.15 KiB.
[2 Jun 2009 5:59]
Jess Balint
Pushed for release in 5.1.8
[23 Jun 2009 13:31]
Tony Bedford
An entry was added to the 5.1.8 changelog: If there was an apostrophe in a comment in a statement that was being sent through Connector/J, the apostrophe was still recognized as a quote and put the state machine in EscapeTokenizer into the inQuotes state. This led to further parse errors. For example, consider the following statement: String sql = "-- Customer's zip code will be fixed\n" + "update address set zip_code = 99999\n" + "where not regexp '^[0-9]{5}([[.-.]])?([0-9]{4})?$'"; When passed through Connector/J, the EscapeTokenizer did not recognize that the first apostrophe was in a comment and thus set inQuotes to true. When that happened, the quote count was incorrect and thus the regular expression did not appear to be in quotes. With the parser not detecting that the regular expression was in quotes, the curly braces were recognized as escape sequences and were removed from the regular expression, breaking it. The server thus received SQL such as: -- Customer's zip code will be fixed update address set zip_code = '99999' where not regexp '^[0-9]([[.-.]])?([0-9])?$'