4 messages in com.mysql.lists.plusplusRE: Inconsistency storing binary data...
FromSent OnAttachments
Erik Perrhoe (Computer Consultant)18 May 2002 11:37 
Erik Perrhoe (Computer Consultant)18 May 2002 11:37 
Erik Perrhoe (Computer Consultant)18 May 2002 11:37 
Erik Perrhoe (Computer Consultant)19 May 2002 13:47 
Subject:RE: Inconsistency storing binary data in a BLOB column
From:Erik Perrhoe (Computer Consultant) (mysq@compsalot.com)
Date:05/19/2002 01:47:36 PM
List:com.mysql.lists.plusplus

Problems arise after I insert the binary data into the MySQL database using the query construct (ie: query << "INSERT INTO files (content) VALUES (\"" << escape << compressed_data << "\")"; where compressed_data is the resulting buffer from a zlib compress() operation.

Hi,

The place to start is to take a close look at the output of escape << compressed_data

Or you can sidestep the issue altogether by converting to an ASCII Hex string instead. e.g. 0xA041..... etc...

The disadvantage of the Hex string approach is that it doubles the size of the data transfer (the storage size is the same). The advantage is that it has been totally reliable for me and avoids a whole slew of problems when trying to pass binary data around...

Another thought about your problem is to be very careful of Unicode vs SBCS..... a mismatch will quickly and invisibly torpedo your program....

Hope this Helps,

Erik Perrohe -- Seattle, USA