From 4e955852b9d59338a5bb50facc1594e97b8ca2d8 Mon Sep 17 00:00:00 2001 From: Constantin Michael Date: Wed, 11 May 2011 11:12:49 +0200 Subject: Add transaction support to database --- odb/pgsql/database.cxx | 15 +++++++++------ odb/pgsql/database.hxx | 10 ++++++---- 2 files changed, 15 insertions(+), 10 deletions(-) (limited to 'odb') 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 #include #include +#include #include @@ -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 +#include + #include #include +#include #include +#include #include @@ -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 -- cgit v1.1