From 6de3db919419051a68082a64b107ce2ca52e72ad Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 19 Sep 2014 14:43:55 +0200 Subject: Call tracer::prepare() before actually preparing statement This way we give the user the ability to see an invalid statement that would cause the preparation step to fail. --- odb/mysql/statement.cxx | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/odb/mysql/statement.cxx b/odb/mysql/statement.cxx index afc6656..4b80913 100644 --- a/odb/mysql/statement.cxx +++ b/odb/mysql/statement.cxx @@ -183,19 +183,22 @@ namespace odb statement:: ~statement () { + if (stmt_ != 0) { - odb::tracer* t; - if ((t = conn_.transaction_tracer ()) || - (t = conn_.tracer ()) || - (t = conn_.database ().tracer ())) - t->deallocate (conn_, *this); - } + { + odb::tracer* t; + if ((t = conn_.transaction_tracer ()) || + (t = conn_.tracer ()) || + (t = conn_.database ().tracer ())) + t->deallocate (conn_, *this); + } - // Let the connection handle the release of the statement (it - // may delay the actual freeing if it will mess up the currently - // active statement). - // - conn_.free_stmt_handle (stmt_); + // Let the connection handle the release of the statement (it + // may delay the actual freeing if it will mess up the currently + // active statement). + // + conn_.free_stmt_handle (stmt_); + } } const char* statement:: -- cgit v1.1