diff options
-rw-r--r-- | odb/pgsql/database.cxx | 4 | ||||
-rw-r--r-- | odb/pgsql/database.ixx | 2 | ||||
-rw-r--r-- | odb/pgsql/polymorphic-object-statements.txx | 2 | ||||
-rw-r--r-- | odb/pgsql/transaction-impl.hxx | 5 | ||||
-rw-r--r-- | odb/pgsql/transaction-impl.ixx | 14 | ||||
-rw-r--r-- | odb/pgsql/transaction.hxx | 3 | ||||
-rw-r--r-- | odb/pgsql/transaction.ixx | 8 |
7 files changed, 15 insertions, 23 deletions
diff --git a/odb/pgsql/database.cxx b/odb/pgsql/database.cxx index 51752d7..b4d3732 100644 --- a/odb/pgsql/database.cxx +++ b/odb/pgsql/database.cxx @@ -282,7 +282,9 @@ namespace odb cp = factory_->connect (); pgsql::connection& c ( - cp != 0 ? *cp : transaction::current ().connection ()); + cp != 0 + ? *cp + : transaction::current ().connection (const_cast<database&> (*this))); // If we are in the user's transaction then things are complicated. When // we try to execute SELECT on a non-existent table, PG "poisons" the diff --git a/odb/pgsql/database.ixx b/odb/pgsql/database.ixx index 3e3d63e..ecc94f9 100644 --- a/odb/pgsql/database.ixx +++ b/odb/pgsql/database.ixx @@ -594,7 +594,7 @@ namespace odb { // Throws if not in transaction. // - pgsql::connection& c (transaction::current ().connection ()); + pgsql::connection& c (transaction::current ().connection (*this)); return c.prepare_query<T> (n, q); } diff --git a/odb/pgsql/polymorphic-object-statements.txx b/odb/pgsql/polymorphic-object-statements.txx index 7f2aadd..8472fca 100644 --- a/odb/pgsql/polymorphic-object-statements.txx +++ b/odb/pgsql/polymorphic-object-statements.txx @@ -129,7 +129,7 @@ namespace odb root_type& robj, const schema_version_migration* svm) { - connection_type& conn (transaction::current ().connection ()); + connection_type& conn (transaction::current ().connection (db)); polymorphic_derived_object_statements& sts ( conn.statement_cache ().find_object<object_type> ()); root_statements_type& rsts (sts.root_statements ()); diff --git a/odb/pgsql/transaction-impl.hxx b/odb/pgsql/transaction-impl.hxx index 59924a0..5c93b0e 100644 --- a/odb/pgsql/transaction-impl.hxx +++ b/odb/pgsql/transaction-impl.hxx @@ -38,17 +38,12 @@ namespace odb virtual void rollback (); - connection_type& - connection (); - private: connection_ptr connection_; }; } } -#include <odb/pgsql/transaction-impl.ixx> - #include <odb/post.hxx> #endif // ODB_PGSQL_TRANSACTION_IMPL_HXX diff --git a/odb/pgsql/transaction-impl.ixx b/odb/pgsql/transaction-impl.ixx deleted file mode 100644 index f812969..0000000 --- a/odb/pgsql/transaction-impl.ixx +++ /dev/null @@ -1,14 +0,0 @@ -// file : odb/pgsql/transaction-impl.ixx -// license : GNU GPL v2; see accompanying LICENSE file - -namespace odb -{ - namespace pgsql - { - inline transaction_impl::connection_type& transaction_impl:: - connection () - { - return *connection_; - } - } -} diff --git a/odb/pgsql/transaction.hxx b/odb/pgsql/transaction.hxx index f1240ec..e83c754 100644 --- a/odb/pgsql/transaction.hxx +++ b/odb/pgsql/transaction.hxx @@ -41,6 +41,9 @@ namespace odb connection_type& connection (); + connection_type& + connection (odb::database&); + // Return current transaction or throw if there is no transaction // in effect. // diff --git a/odb/pgsql/transaction.ixx b/odb/pgsql/transaction.ixx index 7a2c375..31aa603 100644 --- a/odb/pgsql/transaction.ixx +++ b/odb/pgsql/transaction.ixx @@ -39,7 +39,13 @@ namespace odb inline transaction::connection_type& transaction:: connection () { - return implementation ().connection (); + return static_cast<connection_type&> (odb::transaction::connection ()); + } + + inline transaction::connection_type& transaction:: + connection (odb::database& db) + { + return static_cast<connection_type&> (odb::transaction::connection (db)); } inline void transaction:: |