Ticket #1622 (closed defect: fixed)

Opened 6 years ago

Last modified 6 years ago

BLOB support in MySQL driver not working

Reported by: Kosta Owned by: mloskot
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

mysql_blob.patch Download (3.1 KB) - added by Kosta 6 years ago.
bug fixes for BLOB support in MySQL driver
mysql_blob_simple_test.zip Download (2.5 KB) - added by mloskot 6 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.

Change History

Changed 6 years ago by Kosta

bug fixes for BLOB support in MySQL driver

Changed 6 years ago by warmerdam

  • cc warmerdam, hobu added
  • owner changed from warmerdam to mloskot
  • severity changed from major to normal
  • milestone set to 1.4.2

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 6 years ago by mloskot

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.

Changed 6 years ago by mloskot

  • status changed from new to assigned

Changed 6 years ago by mloskot

  • status changed from assigned to closed
  • resolution set to fixed

Applied in r11522.

Changed 6 years ago by mloskot

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.