Bug #51527 | wrong escaping with characterEncoding=MS932 and useServerPrepStmts=false | ||
---|---|---|---|
Submitted: | 25 Feb 2010 19:27 | Modified: | 11 Jan 2011 10:54 |
Reporter: | Andrii Nikitin | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | Connector / J | Severity: | S3 (Non-critical) |
Version: | 5.1.12, 5.1.0 | OS: | Any |
Assigned to: | Tony Bedford | CPU Architecture: | Any |
[25 Feb 2010 19:27]
Andrii Nikitin
[25 Feb 2010 19:28]
Andrii Nikitin
testcase
Attachment: BlobT.java (application/octet-stream, text), 2.64 KiB.
[25 Feb 2010 19:47]
Andrii Nikitin
corrupted blob exported with 'SELECT ... INTO DUMPFILE'
Attachment: out51-corrupted.gif (image/gif, text), 1.23 KiB.
[25 Feb 2010 19:54]
Andrii Nikitin
Comparison of files mysql.gif and out51-corrupted.gif shows that six occurrences of byte '\0' (i.e. 0x00) are replaced with two bytes '\\' and '0' (0x57 and 0x30).
[26 Feb 2010 16:08]
Tonci Grgin
Andrii, there is something else that's wrong here... E:\>fc mysql.gif test.gif Comparing files mysql.gif and TEST.GIF FC: no differences encountered Test case is attached. -Xmx1024M -XX:+UseParallelGC -Dcom.mysql.jdbc.java6.javac=C:\jvms\jdk1.6.0\bin\javac.exe -Dcom.mysql.jdbc.java6.rtjar=C:\jvms\jdk1.6.0\jre\lib\rt.jar -Dcom.mysql.jdbc.testsuite.url.default=jdbc:mysql://opensol:xx/test?user=xx&password=xx&autoReconnect=false&connectTimeout=5000&socketTimeout=30000&useInformationSchema=true&useServerPrepStmts=true&useAffectedRows=false
[26 Feb 2010 16:09]
Tonci Grgin
Test case for our test framework. Tested with JDK 1.5.
Attachment: TestBug51527_1.java (text/x-java), 2.52 KiB.
[2 Mar 2010 15:08]
Andrii Nikitin
Looks problem occurs when useServerPrepStmts=false . C/J produces different escaped string than MySQL server for two-byte-sequence: 0x90 and 0x00 (with characterEncoding=MS932) Extract from general log when inserting BLOB with these two bytes: SET NAMES cp932 INSERT INTO imgdata_tab(img) VALUES (_binary'_\0') But server produces differently escaped sequence (so I assume it expects different sequence also): SET NAMES cp932; select concat(0x90,0x00) into outfile '/tmp/.outfile'; \_\0 (note leading backslash). Also please note that if we do "SET NAMES utf8;", the SELECT statement will return sequence identical to one C/J produces.
[2 Mar 2010 16:09]
Tonci Grgin
Andrii, this could also be due to SQL_MODE, please note the one used.
[3 Mar 2010 8:52]
Andrii Nikitin
sql_mode=""
[3 Mar 2010 9:01]
Andrii Nikitin
With sql_mode="NO_BACKSLASH_ESCAPES" bug is not reproducible.
[11 Jan 2011 10:54]
Tony Bedford
No changelog entry has been created. A note on the problem and solution has been added to the Connector/J: Common Problems and Solutions section of the Connector/J documentation.