On Monday 22 February 2010, Alex Balashov wrote:
Should sql_result_free() always be called, no matter
what the
circumstance, in order to discharge memory allocated to query result
sets and/or metadata?
Or is it not necessary in certain situations, for example when script is
broken via 'exit', i.e.
sql_query("db", "SELECT ...", "res");
if(! $dbr(res=>rows)) {
# Is it necessary to call sql_result_free() here?
exit;
}
Are results implicitly freed at the end of route script execution
anyway? Are they tied to transaction persistence in any way?
Hi Alex,
my understanding of the module is that you need to call sql_result_free() afer
every successful execution of sql_query(). The sql_query structure is not
bound to any transactional behaviour or script routing logic. Daniel, please
correct me when i'm wrong here.
Old results are freed when the module is destroyed as a cleanup, during an
error of query execution and before a new query is started. But as every
single invocation of sql_query could fail, i'd not recommend it to optimize
the free operation away.
Henning