diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2011-11-07 15:00:06 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2011-11-07 15:00:06 +0200 |
commit | 0e37272b9ab8f37ad2f3d37bf6a09c68e5117d02 (patch) | |
tree | 823c0bc76f6c03e9ecedaaad6db719a7b0367299 /odb/pgsql/transaction-impl.cxx | |
parent | 26f53799c911e44da5d229e8f6bf2c40f79c31b1 (diff) |
Add support for SQL statement tracing
Diffstat (limited to 'odb/pgsql/transaction-impl.cxx')
-rw-r--r-- | odb/pgsql/transaction-impl.cxx | 20 |
1 files changed, 20 insertions, 0 deletions
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 <libpq-fe.h> +#include <odb/tracer.hxx> + #include <odb/pgsql/database.hxx> #include <odb/pgsql/connection.hxx> #include <odb/pgsql/error.hxx> @@ -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<PGresult> 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<PGresult> 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<PGresult> h (PQexec (connection_->handle (), "rollback")); if (!h || PGRES_COMMAND_OK != PQresultStatus (h)) |