Hi,
Thanks for the great library, I have a question about re-executing failed
prepared statements...
step 1: have a prepared statement that throws an exception (like in the
example at the end of this email)
step 2: try and execute it again
result: there is a memory leak from
mysql_standard_use_type_backend::pre_use(), because post_use() is not called,
so clean_up() is not called, so this line gets re-executed next time around:
buf_ = new char[5];
Should it be possible to either:
a) re-use the prepared statement again with no explicit tidy up, or
b) re-use the prepared statement after some sort of tidy up (calling
statement::clean_up() seems to clean up too much),
or is re-preparing the only safe thing to do?
Adding a call to mysql_standard_use_type_backend::clean_up() at the start of
mysql_standard_use_type_backend::pre_use() seems to fix this for me (though
perhaps post_use() would be better than clean_up()). Is that a possible fix, or
are all bets off after the exception?
rgds, Gavin
-------------------------------
#include "soci.h"
#include "soci-mysql.h"
#include <iostream>
using namespace soci;
using namespace std;
int main ( int argc, char** argv )
{
session sql(mysql, "dbname=test user=test password=test");
// Intentional bad SQL to trigger exception from backend
statement st = (sql.prepare <<
"BADNESS insert into numbers(value) values(:val)",
use(i));
for (int i = 0; i != 100; ++i) {
try {
st.execute(true);
}
catch ( exception& e ) {
cerr << e.what() << std::endl;
}
}
exit (0);
}
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Soci-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/soci-users