[Serdev] Nested MySQL queries

Andreas Granig andreas.granig at inode.info
Mon Sep 19 17:59:37 UTC 2005


Jan Janak wrote:
> The problem is that the conversion function does not allocate memory for 
> strings and binary data, it just points to the memory region allocated by 
> mysqlclient library. If you call mysql_free_result while the resulting 
> (converted) data structures are still use then the pointers to strings and 
> binary data would point to unallocated memory regions.

Oh, yes, haven't seen this and was surprised about the unexpected 
results when trying it out a few minutes ago...

> You would need to make an explicit copy of all strings and binary data
> before calling mysql_free_result (that would be slower).

Another possibility which is more elegant IMHO is storing the result in 
a void-pointer in db_res_t, where it logically belongs to. Would this be 
a passable solution?

Andy




More information about the Serdev mailing list