8 messages in com.mysql.lists.plusplusproblem on storing and loading blob f...
FromSent OnAttachments
mdib...@fi.uba.ar25 Nov 2003 11:09 
Sinisa Milivojevic26 Nov 2003 03:55 
Tommy Tang26 Nov 2003 19:42 
Sinisa Milivojevic27 Nov 2003 07:01 
Tommy Tang28 Nov 2003 20:17 
Sinisa Milivojevic29 Nov 2003 04:40 
Tommy Tang30 Nov 2003 18:18 
Sinisa Milivojevic01 Dec 2003 03:54 
Subject:problem on storing and loading blob field
From:Tommy Tang (tom@vlinetech.com)
Date:11/26/2003 07:42:41 PM
List:com.mysql.lists.plusplus

Referencing the examples cgi_image.cc and load_file.cc, I wrote a my own example
to practice the blob manipulation, but the result is not as I expected. Can anyone tell me the reason? Thanks a lot in advance.

char szMessage[32]; for ( int i = 0; i < sizeof( szMessage ); i++ ) { szMessage[i] = 'a'; } //add a NULL in the middle of the string to test whether the chars after the
NULL can be stored szMessage[10] = 0;

std::string strMessage( szMessage, sizeof( szMessage ) ); con.select_db("test"); Query query = con.query(); //to test the storing query << "INSERT INTO testblob VALUES(" << rand() << ",\"" << escape <<
strMessage << "\")"; query.execute(); //to test the loading query << "SELECT data FROM testblob"; ResUse res = query.use(); Row row=res.fetch_row(); long unsigned int *jj = res.fetch_lengths(); TRACE("The Length of blob field is %d\n", *jj); memcpy( szMessage, row.raw_data(0), *jj );

The output is "The Length of blob field is 9" ^ ( should be 32,
9 means that all the chars after NULL is truncated)

Best Regards! Tommy