aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2014-09-19 14:43:55 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2014-09-19 14:43:55 +0200
commitc1b5f35457db2cccdebc9bef93126758476a15c1 (patch)
tree0d62809339c26fc2c01403f779c8f06148f1471f
parentaac07705a385505265173aa3f26f24ecf8d7e22c (diff)
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.
-rw-r--r--odb/mssql/statement.cxx15
1 files changed, 8 insertions, 7 deletions
diff --git a/odb/mssql/statement.cxx b/odb/mssql/statement.cxx
index e2022fa..15037a0 100644
--- a/odb/mssql/statement.cxx
+++ b/odb/mssql/statement.cxx
@@ -204,13 +204,6 @@ namespace odb
if (!SQL_SUCCEEDED (r))
translate_error (r, conn_, stmt_);
- // Prepare the statement.
- //
- r = SQLPrepareA (stmt_, (SQLCHAR*) text_, (SQLINTEGER) text_size);
-
- if (!SQL_SUCCEEDED (r))
- translate_error (r, conn_, stmt_);
-
{
odb::tracer* t;
if ((t = conn_.transaction_tracer ()) ||
@@ -218,11 +211,19 @@ namespace odb
(t = conn_.database ().tracer ()))
t->prepare (conn_, *this);
}
+
+ // Prepare the statement.
+ //
+ r = SQLPrepareA (stmt_, (SQLCHAR*) text_, (SQLINTEGER) text_size);
+
+ if (!SQL_SUCCEEDED (r))
+ translate_error (r, conn_, stmt_);
}
statement::
~statement ()
{
+ if (stmt_ != 0)
{
odb::tracer* t;
if ((t = conn_.transaction_tracer ()) ||