From 0e37272b9ab8f37ad2f3d37bf6a09c68e5117d02 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 7 Nov 2011 15:00:06 +0200 Subject: Add support for SQL statement tracing --- odb/pgsql/transaction-impl.cxx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'odb/pgsql/transaction-impl.cxx') diff --git a/odb/pgsql/transaction-impl.cxx b/odb/pgsql/transaction-impl.cxx index e4604e3..ac90e93 100644 --- a/odb/pgsql/transaction-impl.cxx +++ b/odb/pgsql/transaction-impl.cxx @@ -7,6 +7,8 @@ #include +#include + #include #include #include @@ -46,6 +48,12 @@ namespace odb odb::transaction_impl::connection_ = connection_.get (); } + { + odb::tracer* t; + if ((t = connection_->tracer ()) || (t = database_.tracer ())) + t->execute (*connection_, "BEGIN"); + } + auto_handle h (PQexec (connection_->handle (), "begin")); if (!h || PGRES_COMMAND_OK != PQresultStatus (h)) @@ -55,6 +63,12 @@ namespace odb void transaction_impl:: commit () { + { + odb::tracer* t; + if ((t = connection_->tracer ()) || (t = database_.tracer ())) + t->execute (*connection_, "COMMIT"); + } + auto_handle h (PQexec (connection_->handle (), "commit")); if (!h || PGRES_COMMAND_OK != PQresultStatus (h)) @@ -64,6 +78,12 @@ namespace odb void transaction_impl:: rollback () { + { + odb::tracer* t; + if ((t = connection_->tracer ()) || (t = database_.tracer ())) + t->execute (*connection_, "ROLLBACK"); + } + auto_handle h (PQexec (connection_->handle (), "rollback")); if (!h || PGRES_COMMAND_OK != PQresultStatus (h)) -- cgit v1.1