aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2021-04-30 12:06:15 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2021-04-30 12:08:30 +0200
commitc6019273a7564be9ed772d45aa95e09aaff37a23 (patch)
tree501c84ed459866611032a705052aa57045a67c5f
parent38e203158a865d08070a4a72dcc1fee2cdacb952 (diff)
Add transaction::connection(database&) overload
-rw-r--r--odb/pgsql/database.cxx4
-rw-r--r--odb/pgsql/database.ixx2
-rw-r--r--odb/pgsql/polymorphic-object-statements.txx2
-rw-r--r--odb/pgsql/transaction-impl.hxx5
-rw-r--r--odb/pgsql/transaction-impl.ixx14
-rw-r--r--odb/pgsql/transaction.hxx3
-rw-r--r--odb/pgsql/transaction.ixx8
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::