aboutsummaryrefslogtreecommitdiff
path: root/odb/pgsql/section-statements.hxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-09-28 10:51:12 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-09-28 10:51:12 +0200
commit31789cec4f59f7a6fd1e92eac523c595a7b102ac (patch)
tree584244d644ff1c81002f9d1e3f9667f4fb710181 /odb/pgsql/section-statements.hxx
parentec1498dcd925d1c01074114f615b5fd4010ae274 (diff)
Make schema version access (but not modification) thread-safe
Also cache the version in statements so that we don't have to lock the mutex (slow) every time we need to check the version.
Diffstat (limited to 'odb/pgsql/section-statements.hxx')
-rw-r--r--odb/pgsql/section-statements.hxx13
1 files changed, 13 insertions, 0 deletions
diff --git a/odb/pgsql/section-statements.hxx b/odb/pgsql/section-statements.hxx
index d75fd66..e7dcd9e 100644
--- a/odb/pgsql/section-statements.hxx
+++ b/odb/pgsql/section-statements.hxx
@@ -10,11 +10,14 @@
#include <cstddef> // std::size_t
#include <odb/forward.hxx>
+#include <odb/schema-version.hxx>
#include <odb/traits.hxx>
#include <odb/pgsql/version.hxx>
#include <odb/pgsql/binding.hxx>
#include <odb/pgsql/statement.hxx>
+#include <odb/pgsql/connection.hxx>
+#include <odb/pgsql/database.hxx>
#include <odb/pgsql/pgsql-fwd.hxx> // Oid
#include <odb/pgsql/details/export.hxx>
@@ -49,6 +52,15 @@ namespace odb
connection_type&
connection () {return conn_;}
+ const schema_version_migration&
+ version_migration (const char* name = "") const
+ {
+ if (svm_ == 0)
+ svm_ = &conn_.database ().schema_version_migration (name);
+
+ return *svm_;
+ }
+
image_type&
image () {return image_;}
@@ -152,6 +164,7 @@ namespace odb
protected:
connection_type& conn_;
+ mutable const schema_version_migration* svm_;
// These come from object_statements.
//