Bug #63526 | Valid script fails | ||
---|---|---|---|
Submitted: | 1 Dec 2011 22:30 | Modified: | 9 Mar 2012 9:58 |
Reporter: | Javier Ortiz | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | Connector / J | Severity: | S2 (Serious) |
Version: | 5.5.18 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[1 Dec 2011 22:30]
Javier Ortiz
[1 Dec 2011 22:30]
Javier Ortiz
Referenced script
Attachment: xinco_MySQL.sql (application/octet-stream, text), 53.71 KiB.
[1 Dec 2011 22:31]
Javier Ortiz
Related Workbench file
Attachment: Xinco.mwb (application/octet-stream, text), 63.06 KiB.
[2 Dec 2011 6:56]
Tonci Grgin
Hi Javier and thanks for elaborate bug report. Please do tell us the SQL_MODE MySQL server is in when the test fails.
[2 Dec 2011 12:17]
Javier Ortiz
What do you mean by SQL MODE and how can I figure it out?
[2 Dec 2011 12:55]
Tonci Grgin
http://dev.mysql.com/doc/refman/5.5/en/server-sql-mode.html
[8 Dec 2011 21:11]
Matthias Bläsing
I'm the cited analyst of the original bug. The server yields this: SELECT @@GLOBAL.sql_mode; => nothing SELECT @@SESSION.sql_mode; => STRICT_TRANS_TABLES
[14 Dec 2011 12:19]
Matthias Bläsing
I think I found it: The problem happens in com.mysql.jdbc.EscapeProcessor#escapeSQL. The function recognizes the string in the create table statement as an escape sequence (line 136+138). The if construct beginning in line 182 tries to match a white-space collapsed version of the string to prefixes for valid jdbc-escapes (till line 300). No matching escape sequence is found and no else is defined, so neigther the token, nor a replacement are added to the resulting escaped SQL string. So I propose to add a final else-branch to the construnct at line 301: else { newSql.append(token); }
[20 Jan 2012 8:53]
Tonci Grgin
Thanks Matthias but it's not the case... Latest sources show } else { newSql.append(token); // it's just part of the query } @ line 301 but it still fails.
[21 Jan 2012 22:01]
Matthias Bläsing
Hey, I had another look at the code at I think I'm still correct. You see the else-branch of the if statement starting on line 136 but my correction would apply to the inner if starting on line 182. That swallows the tokeen. But I see another possible fix. The EscapeTokenizer does not take back-ticks into account and so does not parse the whole quoted sequenze as one token. So adding this to the cases sould fix it.
[23 Jan 2012 6:53]
Tonci Grgin
Matthias, yes you were right. I picked up code from outer block. Fix, as you proposed it is in review.
[9 Mar 2012 9:58]
Tonci Grgin
Pushed up to rev. 1122.
[22 Mar 2012 20:15]
John Russell
Added to changelog for 5.5.19: A problem with processing escape sequences (in com.mysql.jdbc.EscapeProcessor#escapeSQL) could cause certain statements to fail. For example, a CREATE TABLE statement with a clause such as CONSTRAINT `fk_` was not parsed correctly.