List:MySQL++« Previous MessageNext Message »
From:Bill K Date:April 17 2006 12:31pm
Subject:Re: Retrieving Binary Data
View as plain text  
Hi Chris,

Thanks. That seems to work. I think result.fetch_lengths() is the only 
method I didn't try. =) Seems almost like there should be a function in 
the ColData object (retrieved by 'row.at(n)') to get the length as well.

Thanks again!

- Bill Krahmer


Chris Frey wrote:
> Off hand, it's something like this:
>
>         Result result = query.store();
>         Result::iterator i = result.begin();
>         Row row;
>
>         // loop through all results
>         for( ; i != result.end(); i++ )
>         {
>                 row = *i;
>
>                 unsigned long *col_lengths = result.fetch_lengths();
>
> 		// row.raw_data(0) is the first selected column
> 		// and col_lengths[0] is the size of it
>
> 		// do something...
> 		memcpy(dest, row.raw_data(0), col_lengths[0]);
>         }
>
> - Chris
>
> On Sun, Apr 16, 2006 at 09:57:09PM -0500, Bill K wrote:
>   
>> Hello,
>>
>> After trial and error over a few hours, it looks like retrieving binary 
>> data that contains 0 (null) characters is not possible with mysql++. Is 
>> this correct?
>>
>> I am using mysql++ 2.1.1 and MySQL Server 5.0
>>
>> What I am doing with mysql++ is executing this:
>> "SELECT pri_key, CAST(message AS BINARY) message FROM blockedmessages;"
>>
>> The message column is defined as a BLOB in MySQL.
>>
>> The row.at(1).size() and row.at(1).length() return the length of the 
>> data as if it were a string (terminated by the first occurring null 
>> character). There seems to be no way with mysql++ to easily access this 
>> binary data in full.
>>
>> When I hard code a malloc const char* to the right length of the data, I 
>> can see that all the binary is actually put into memory, but there is no 
>> reference provided to access it. You just have to know how long the data 
>> really is and use a malloc or something.
>>
>> Am I right, or am I missing something?
>>
>> Thanks!
>>
>> - Bill Krahmer
>>
>>
>>
>> -- 
>> MySQL++ Mailing List
>> For list archives: http://lists.mysql.com/plusplus
>> To unsubscribe:    http://lists.mysql.com/plusplus?unsub=1
>>     
>
>   
Thread
Retrieving Binary DataBill K17 Apr
  • Re: Retrieving Binary DataChris Frey17 Apr
    • Re: Retrieving Binary DataBill K17 Apr