[Serdev] Nested MySQL queries
Jan Janak
jan at iptel.org
Mon Sep 19 17:37:41 UTC 2005
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.
You would need to make an explicit copy of all strings and binary data
before calling mysql_free_result (that would be slower).
Jan.
On 19-09-2005 19:16, Andreas Granig wrote:
> Hi,
>
> I've reported a problem with nested queries using the mysql module a few
> weeks ago. The problem was, that a my_con structure overwrites it's
> stored mysql result for each query, so in case of a nested query using
> the same my_con the inner query overwrites the result of the outer
> query, causing a memory leak (note that it doesn't help to use different
> db_con_t because they could internally share the same my_con for a
> common db).
>
> Now I've digged a little bit in mysql-module's source code, and the
> mysql result stored in the my_con connection is only used in
> dbase.c:store_result() and it's called functions.
>
> So is there any reason for not calling mysql_free_result() at the end of
> store_result()? Because doing so would allow one to perform nested queries.
>
> Comments?
>
> Andy
>
> _______________________________________________
> Serdev mailing list
> serdev at lists.iptel.org
> http://lists.iptel.org/mailman/listinfo/serdev
More information about the Serdev
mailing list