aboutsummaryrefslogtreecommitdiff
path: root/odb/pgsql/statement.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-11-07 15:00:06 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-11-07 15:00:06 +0200
commit0e37272b9ab8f37ad2f3d37bf6a09c68e5117d02 (patch)
tree823c0bc76f6c03e9ecedaaad6db719a7b0367299 /odb/pgsql/statement.cxx
parent26f53799c911e44da5d229e8f6bf2c40f79c31b1 (diff)
Add support for SQL statement tracing
Diffstat (limited to 'odb/pgsql/statement.cxx')
-rw-r--r--odb/pgsql/statement.cxx61
1 files changed, 59 insertions, 2 deletions
diff --git a/odb/pgsql/statement.cxx b/odb/pgsql/statement.cxx
index 049a00d..8a20456 100644
--- a/odb/pgsql/statement.cxx
+++ b/odb/pgsql/statement.cxx
@@ -9,6 +9,8 @@
#include <libpq-fe.h>
+#include <odb/tracer.hxx>
+
#include <odb/pgsql/pgsql-oid.hxx>
#include <odb/pgsql/statement.hxx>
#include <odb/pgsql/connection.hxx>
@@ -68,6 +70,14 @@ namespace odb
if (deallocated_)
return;
+ {
+ odb::tracer* t;
+ if ((t = conn_.transaction_tracer ()) ||
+ (t = conn_.tracer ()) ||
+ (t = conn_.database ().tracer ()))
+ t->deallocate (conn_, *this);
+ }
+
string s ("deallocate \"");
s += name_;
s += "\"";
@@ -79,17 +89,26 @@ namespace odb
statement::
statement (connection& conn,
const string& name,
- const string& stmt,
+ const string& text,
const Oid* types,
size_t types_count)
: conn_ (conn),
name_ (name),
+ text_ (text),
deallocated_ (false)
{
+ {
+ odb::tracer* t;
+ if ((t = conn_.transaction_tracer ()) ||
+ (t = conn_.tracer ()) ||
+ (t = conn_.database ().tracer ()))
+ t->prepare (conn_, *this);
+ }
+
auto_handle<PGresult> h (
PQprepare (conn_.handle (),
name_.c_str (),
- stmt.c_str (),
+ text_.c_str (),
static_cast<int> (types_count),
types));
@@ -102,6 +121,12 @@ namespace odb
//
}
+ const char* statement::
+ text () const
+ {
+ return text_.c_str ();
+ }
+
void statement::
bind_param (native_binding& n, const binding& b)
{
@@ -384,6 +409,14 @@ namespace odb
if (param_ != 0)
bind_param (*native_param_, *param_);
+ {
+ odb::tracer* t;
+ if ((t = conn_.transaction_tracer ()) ||
+ (t = conn_.tracer ()) ||
+ (t = conn_.database ().tracer ()))
+ t->execute (conn_, *this);
+ }
+
bool in (native_param_ != 0);
handle_.reset (
@@ -478,6 +511,14 @@ namespace odb
{
bind_param (native_param_, param_);
+ {
+ odb::tracer* t;
+ if ((t = conn_.transaction_tracer ()) ||
+ (t = conn_.tracer ()) ||
+ (t = conn_.database ().tracer ()))
+ t->execute (conn_, *this);
+ }
+
auto_handle<PGresult> h (
PQexecPrepared (conn_.handle (),
name_.c_str (),
@@ -570,6 +611,14 @@ namespace odb
{
bind_param (native_param_, param_);
+ {
+ odb::tracer* t;
+ if ((t = conn_.transaction_tracer ()) ||
+ (t = conn_.tracer ()) ||
+ (t = conn_.database ().tracer ()))
+ t->execute (conn_, *this);
+ }
+
auto_handle<PGresult> h (
PQexecPrepared (conn_.handle (),
name_.c_str (),
@@ -627,6 +676,14 @@ namespace odb
if (param_ != 0)
bind_param (native_param_, *param_);
+ {
+ odb::tracer* t;
+ if ((t = conn_.transaction_tracer ()) ||
+ (t = conn_.tracer ()) ||
+ (t = conn_.database ().tracer ()))
+ t->execute (conn_, *this);
+ }
+
auto_handle<PGresult> h (
PQexecPrepared (conn_.handle (),
name_.c_str (),