diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2011-08-30 16:10:02 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2011-08-30 16:10:30 +0200 |
commit | 9fce9a7250f63a2a3cceeb0aac7b22d5dd7e6915 (patch) | |
tree | dd20f89ddd286f663aaf881835970c03cc628855 /odb/pgsql/transaction-impl.cxx | |
parent | 44a26d189e186ac10c4a80c4dbb68d65927b12a9 (diff) |
Implement uniform handle management across all databases
Also use the auto_handle template instead of the raw handle in connection,
statement, and result classes. This removes a lot of brittle "exception
safety guarantee" code that we had in those classes.
Diffstat (limited to 'odb/pgsql/transaction-impl.cxx')
-rw-r--r-- | odb/pgsql/transaction-impl.cxx | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/odb/pgsql/transaction-impl.cxx b/odb/pgsql/transaction-impl.cxx index c3ce31d..e4604e3 100644 --- a/odb/pgsql/transaction-impl.cxx +++ b/odb/pgsql/transaction-impl.cxx @@ -12,7 +12,7 @@ #include <odb/pgsql/error.hxx> #include <odb/pgsql/exceptions.hxx> #include <odb/pgsql/transaction-impl.hxx> -#include <odb/pgsql/result-ptr.hxx> +#include <odb/pgsql/auto-handle.hxx> namespace odb { @@ -46,8 +46,7 @@ namespace odb odb::transaction_impl::connection_ = connection_.get (); } - result_ptr r (PQexec (connection_->handle (), "begin")); - PGresult* h (r.get ()); + auto_handle<PGresult> h (PQexec (connection_->handle (), "begin")); if (!h || PGRES_COMMAND_OK != PQresultStatus (h)) translate_error (*connection_, h); @@ -56,8 +55,7 @@ namespace odb void transaction_impl:: commit () { - result_ptr r (PQexec (connection_->handle (), "commit")); - PGresult* h (r.get ()); + auto_handle<PGresult> h (PQexec (connection_->handle (), "commit")); if (!h || PGRES_COMMAND_OK != PQresultStatus (h)) translate_error (*connection_, h); @@ -66,8 +64,7 @@ namespace odb void transaction_impl:: rollback () { - result_ptr r (PQexec (connection_->handle (), "rollback")); - PGresult* h (r.get ()); + auto_handle<PGresult> h (PQexec (connection_->handle (), "rollback")); if (!h || PGRES_COMMAND_OK != PQresultStatus (h)) translate_error (*connection_, h); |