aboutsummaryrefslogtreecommitdiff
path: root/common/threads/driver.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-06-21 10:39:59 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-06-21 10:39:59 +0200
commit6cd8b9f561b912f264ba4f723845935c40a3cb95 (patch)
tree5983e0af3d2ee621242ca6707a58c89b9914d8f0 /common/threads/driver.cxx
parent236cd9bb1dd022e64d690c9b0080d1a15c5f61c7 (diff)
Add support for running tests in dynamic multi-database mode
Only possible in the development build system at this stage.
Diffstat (limited to 'common/threads/driver.cxx')
-rw-r--r--common/threads/driver.cxx18
1 files changed, 12 insertions, 6 deletions
diff --git a/common/threads/driver.cxx b/common/threads/driver.cxx
index 0714d4a..3114072 100644
--- a/common/threads/driver.cxx
+++ b/common/threads/driver.cxx
@@ -17,10 +17,10 @@
#include <odb/details/shared-ptr.hxx>
#include <odb/details/thread.hxx>
-#include <common/config.hxx> // DATABASE_SQLITE
+#include <common/config.hxx> // DATABASE_*
#include <common/common.hxx>
-#ifdef DATABASE_SQLITE
+#if defined(DATABASE_SQLITE) || defined(DATABASE_COMMON)
# include <odb/sqlite/database.hxx>
#endif
@@ -70,7 +70,7 @@ struct task
{
try
{
-#ifndef DATABASE_SQLITE
+#if !defined(DATABASE_SQLITE) && !defined(DATABASE_COMMON)
transaction t (db_.begin ());
#else
// SQLite has a peculiar table locking mode (shared cache)
@@ -79,10 +79,16 @@ struct task
// perspective. One way to work around this problem is to
// start a "write" transaction as such right away.
//
- transaction t (
- static_cast<odb::sqlite::database&> (db_).begin_immediate ());
-#endif
+ transaction t;
+ if (db_.id () != odb::id_sqlite)
+ t.reset (db_.begin ());
+ else
+ {
+ t.reset (
+ static_cast<odb::sqlite::database&> (db_).begin_immediate ());
+ }
+#endif
auto_ptr<object> o (db_.load<object> (id));
assert (o->str_ == "first object");
o->str_ = "another value";