Bug #43759 | ResultSet.deleteRow() corrupts generated DELETE SQL for binary primary key | ||
---|---|---|---|
Submitted: | 19 Mar 2009 19:26 | Modified: | 16 Sep 2009 13:47 |
Reporter: | Chris Lamprecht | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | Connector / J | Severity: | S2 (Serious) |
Version: | 5.1.7 | OS: | Any |
Assigned to: | Mark Matthews | CPU Architecture: | Any |
Tags: | BINARY, character encoding, deleteRow |
[19 Mar 2009 19:26]
Chris Lamprecht
[19 Mar 2009 19:27]
Chris Lamprecht
Testcase Java source code
Attachment: TestDeleteRowBinaryColumn.java (application/octet-stream, text), 3.57 KiB.
[20 Mar 2009 18:29]
Tonci Grgin
Hi Chris and thanks for excellent report. I can't shake off feeling there's something wrong with encoding... Can you please attach my.cnf file and output of SHOW CREATE TABLE for test table. A general query log from MySQL server at the time of testing would be nice too.
[20 Mar 2009 18:33]
Tonci Grgin
Personally, I think this is a bug and if you don't respond I'll mark it verified anyway. DELETE statement just doesn't look right: 2 Query DELETE FROM `test`.`bug43759` WHERE `test`.`bug43759`.`bincolumn`<=>'#Eg��͐' ^ here
[20 Mar 2009 18:35]
Tonci Grgin
Ummm, "here" was aimed at
[20 Mar 2009 18:45]
Chris Lamprecht
Hi Tonci, Thanks for the reply. I'll attach a my.cnf in a moment, and I'll try to get a general query log after that. Here is the show create table for the test table used in my java test program: CREATE TABLE `testtable_bincolumn` ( `bincolumn` binary(8) NOT NULL, PRIMARY KEY (`bincolumn`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1
[20 Mar 2009 18:47]
Chris Lamprecht
my.cnf file
Attachment: testcase_my.cnf (, text), 901 bytes.
[20 Mar 2009 19:10]
Chris Lamprecht
server log file while running my java testcase
Attachment: gandalf.log (text/plain), 2.58 KiB.
[20 Mar 2009 19:18]
Chris Lamprecht
I added the server log file captured while running the testcase. Since it contains binary data for the DELETE queries in question, you might need to view it using a utility such as unix's "od" tool. I view it like this: od -t x1z gandalf.log The delete queries look like this (there are two of them): DELETE FROM `chris`.`testtable_bincolumn` WHERE `chris`.`testtable_bincolumn`.`bincolumn`<=>'BINARY_DATA' In particular, when viewing it like this, here are the bytes that I see for the BINARY_DATA for the two DELETE queries -- these are the bytes inside the single quotes: 01 23 45 67 89 ab cd 9d 01 23 45 67 89 ab cd 5c 30 Note that the first series of bytes should be "01 23 45 67 89 ab cd 90", so the last byte is being corrupted from "90" to "9d". The second one should be "01 23 45 67 89 ab cd 00", and it looks like the last "00" is being escaped as "\0". Since the correct row is being deleted in the DB, this seems to be correct. Let me know if I can provide any other information. thanks
[20 Mar 2009 20:52]
Tonci Grgin
Chris, thanks for info. It's almost Saturday here so I'll get back to this after weekend.
[6 Apr 2009 7:34]
Tonci Grgin
Chris, you are absolutely right, verified as described with test case attached. Looking into general query log with hex editor, last byte in 1 Query DELETE FROM `test`.`bug43759` WHERE `test`.`bug43759`.`bincolumn`<=> ... *is* 9D and not 90. Test case works as expected in cl client.
[20 Aug 2009 21:36]
Mark Matthews
Fixed for 5.1.9.
[16 Sep 2009 13:47]
Tony Bedford
An entry was added to the 5.1.9 changelog: Calling ResultSet.deleteRow() on a table with a primary key of type BINARY(8) silently failed to delete the row, but only in some repeatable cases. The generated DELETE statement generated corrupted part of the primary key data. Specifically, one of the bytes was changed from 0x90 to 0x9D, although the corruption appeared to be different depending on whether the application was run on Windows or Linux.