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
commita881873f216c6311118449ee433ac6cfcd7904a6 (patch)
treed4f273eaf71eb1765694907484e6372a47b0dc37
parentef124bac460467f7e2037f034740b2d4a891fe6e (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/oracle/statement.cxx30
1 files changed, 21 insertions, 9 deletions
diff --git a/odb/oracle/statement.cxx b/odb/oracle/statement.cxx
index 5ad867a..4032138 100644
--- a/odb/oracle/statement.cxx
+++ b/odb/oracle/statement.cxx
@@ -137,7 +137,7 @@ namespace odb
statement::
~statement ()
{
- if (empty ())
+ if (stmt_ == 0)
return;
{
@@ -262,6 +262,21 @@ namespace odb
if (*text == '\0')
return;
+ {
+ odb::tracer* t;
+ if ((t = conn_.transaction_tracer ()) ||
+ (t = conn_.tracer ()) ||
+ (t = conn_.database ().tracer ()))
+ {
+ // Temporarily store the statement text in unbind data so that
+ // text() which may be called by the tracer can access it.
+ //
+ udata_ = reinterpret_cast<unbind*> (const_cast<char*> (text));
+ t->prepare (conn_, *this);
+ udata_ = 0;
+ }
+ }
+
OCIError* err (conn_.error_handle ());
OCIStmt* handle (0);
@@ -279,19 +294,16 @@ namespace odb
translate_error (conn_, r);
stmt_.reset (handle, OCI_STRLS_CACHE_DELETE, err);
-
- {
- odb::tracer* t;
- if ((t = conn_.transaction_tracer ()) ||
- (t = conn_.tracer ()) ||
- (t = conn_.database ().tracer ()))
- t->prepare (conn_, *this);
- }
}
const char* statement::
text () const
{
+ if (stmt_ == 0)
+ // See init() above for details on what's going on here.
+ //
+ return udata_ != 0 ? reinterpret_cast<const char*> (udata_) : "";
+
OCIError* err (conn_.error_handle ());
OraText* s (0);