aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConstantin Michael <constantin@codesynthesis.com>2011-05-11 11:12:49 +0200
committerConstantin Michael <constantin@codesynthesis.com>2011-05-11 11:22:46 +0200
commit4e955852b9d59338a5bb50facc1594e97b8ca2d8 (patch)
tree7839b4c04a49b89873d98c4156b142a35a5fb395
parent78e81069aadc609aee1e4b8137516d9cfce47b0a (diff)
Add transaction support to database
-rw-r--r--odb/pgsql/database.cxx15
-rw-r--r--odb/pgsql/database.hxx10
2 files changed, 15 insertions, 10 deletions
diff --git a/odb/pgsql/database.cxx b/odb/pgsql/database.cxx
index 887061b..080b17f 100644
--- a/odb/pgsql/database.cxx
+++ b/odb/pgsql/database.cxx
@@ -8,6 +8,7 @@
#include <odb/pgsql/database.hxx>
#include <odb/pgsql/exceptions.hxx>
#include <odb/pgsql/connection-factory.hxx>
+#include <odb/pgsql/transaction.hxx>
#include <odb/pgsql/details/options.hxx>
@@ -214,11 +215,13 @@ namespace odb
// {
// }
- // @@ Implement on completion of supporting code.
- //
- // transaction_impl* database::
- // begin ()
- // {
- // }
+ transaction_impl* database::
+ begin ()
+ {
+ if (transaction::has_current ())
+ throw already_in_transaction ();
+
+ return new transaction_impl (*this);
+ }
}
}
diff --git a/odb/pgsql/database.hxx b/odb/pgsql/database.hxx
index 833e472..a45fbb0 100644
--- a/odb/pgsql/database.hxx
+++ b/odb/pgsql/database.hxx
@@ -14,9 +14,13 @@
#include <odb/database.hxx>
+#include <odb/details/shared-ptr.hxx>
+
#include <odb/pgsql/version.hxx>
#include <odb/pgsql/forward.hxx>
+#include <odb/pgsql/connection.hxx>
#include <odb/pgsql/connection-factory.hxx>
+#include <odb/pgsql/transaction-impl.hxx>
#include <odb/pgsql/details/export.hxx>
@@ -86,10 +90,8 @@ namespace odb
// execute (const char* statement, std::size_t length);
public:
- // @@ Implement on completion of supporting code.
- //
- // virtual transaction_impl*
- // begin ();
+ virtual transaction_impl*
+ begin ();
public:
details::shared_ptr<connection_type>