Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#1622 closed defect (fixed)

BLOB support in MySQL driver not working

Reported by: Kosta Owned by: Mateusz Łoskot
Priority: normal Milestone: 1.4.2
Component: OGR_SF Version: unspecified
Severity: normal Keywords: MySQL BLOB
Cc: warmerdam, hobu

Description

The BLOB support in the MySQL driver is completely messed up:

  1. During field type determination MySQL FIELD_TYPE_BLOB is assigned as OFTString (ogrmysqlresultlayer.cpp: 163).
  2. The MySQL types FIELD_TYPE_TINY_BLOB, FIELD_TYPE_MEDIUM_BLOB, and FIELD_TYPE_LONG_BLOB are not handled (ogrmysqlresultlayer.cpp: 163).
  3. In CreateField?() the case of OFTBinary is not handled (ogrmysqltablelayer.cpp: 887).
  4. In CreateFeature?() (ogrmysqltablelayer.cpp: 735) the call to GetFieldAsString?() will truncate binary data to something about 40 bytes (~80 hex digits => see TEMP_BUFFER_SIZE in ogrfeature.cpp: 949).
  5. Binary data must/should be supplied to MySQL via "x'<hex digits>'".

A patch fixing the above issues is attached...

The patch also fixes another issue:

Attachments (2)

mysql_blob.patch (3.1 KB) - added by Kosta 13 years ago.
bug fixes for BLOB support in MySQL driver
mysql_blob_simple_test.zip (2.5 KB) - added by Mateusz Łoskot 13 years ago.
This is simple test of read and write BLOB data to MySQL database. This test uses WKB stream read from multipoint.wkb file, as a sample binary data.

Download all attachments as: .zip

Change History (6)

Changed 13 years ago by Kosta

Attachment: mysql_blob.patch added

bug fixes for BLOB support in MySQL driver

comment:1 Changed 13 years ago by warmerdam

Cc: warmerdam hobu added
Milestone: 1.4.2
Owner: changed from warmerdam to Mateusz Łoskot
Severity: majornormal

Mateusz,

Please verify, incorporate and test.

I don't know if there is a mysql test script currently. If not, I'd suggest you add a long term todo item to create one rather than do it immediately. I've added Howard to the cc list in case he would like to take this ticket or has some opinions on the change.

Changed 13 years ago by Mateusz Łoskot

Attachment: mysql_blob_simple_test.zip added

This is simple test of read and write BLOB data to MySQL database. This test uses WKB stream read from multipoint.wkb file, as a sample binary data.

comment:2 Changed 13 years ago by Mateusz Łoskot

Status: newassigned

comment:3 Changed 13 years ago by Mateusz Łoskot

Resolution: fixed
Status: assignedclosed

Applied in r11522.

comment:4 Changed 13 years ago by Mateusz Łoskot

Also applied to the stable branch 1.4, so it will be included in new coming 1.4.2 (r11523).

Note: See TracTickets for help on using tickets.