aboutsummaryrefslogtreecommitdiff
path: root/odb
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-04-26 11:43:10 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-04-26 11:43:10 +0200
commitf85d634ac895a6ad937d8bc0861cc483d07da1cb (patch)
treea165a322380ae69c21bf2e3c48e1c6738d971a76 /odb
parent1bcf16e4a89a09346813c1c47e75da99f74a65fe (diff)
Add database name to changelog
Diffstat (limited to 'odb')
-rw-r--r--odb/generator.cxx10
-rw-r--r--odb/relational/changelog.cxx7
-rw-r--r--odb/relational/generate.hxx2
-rw-r--r--odb/semantics/relational/changelog.cxx3
-rw-r--r--odb/semantics/relational/changelog.hxx7
5 files changed, 23 insertions, 6 deletions
diff --git a/odb/generator.cxx b/odb/generator.cxx
index 1ca094f..a4e1303 100644
--- a/odb/generator.cxx
+++ b/odb/generator.cxx
@@ -251,6 +251,14 @@ generate (options const& ops,
xml::parser p (is, in_log_path.string ());
old_changelog.reset (new (shared) sema_rel::changelog (p));
+
+ if (old_changelog->database () != db.string ())
+ {
+ cerr << in_log_path << ": error: wrong database '" <<
+ old_changelog->database () << "', expected '" << db <<
+ "'" << endl;
+ throw generator::failed ();
+ }
}
catch (const ios_base::failure& e)
{
@@ -270,7 +278,7 @@ generate (options const& ops,
old_changelog.get (),
in_log_path.string (),
out_log_path.string (),
- ops.init_changelog ());
+ ops);
}
// Output files.
diff --git a/odb/relational/changelog.cxx b/odb/relational/changelog.cxx
index af6371a..bae2a2c 100644
--- a/odb/relational/changelog.cxx
+++ b/odb/relational/changelog.cxx
@@ -655,9 +655,10 @@ namespace relational
changelog* old,
std::string const& in_name,
std::string const& out_name,
- bool force_init)
+ options const& ops)
{
- cutl::shared_ptr<changelog> cl (new (shared) changelog);
+ cutl::shared_ptr<changelog> cl (
+ new (shared) changelog (ops.database ()[0].string ()));
graph& g (*cl);
if (old == 0)
@@ -673,7 +674,7 @@ namespace relational
throw operation_failed ();
}
- if (!force_init)
+ if (!ops.init_changelog ())
cerr << out_name << ": info: initializing changelog with base " <<
"version " << mv.base << endl;
diff --git a/odb/relational/generate.hxx b/odb/relational/generate.hxx
index 864f241..d26488b 100644
--- a/odb/relational/generate.hxx
+++ b/odb/relational/generate.hxx
@@ -49,7 +49,7 @@ namespace relational
semantics::relational::changelog* old, // Can be NULL.
std::string const& in_name,
std::string const& out_name,
- bool force_init);
+ options const&);
}
namespace schema
diff --git a/odb/semantics/relational/changelog.cxx b/odb/semantics/relational/changelog.cxx
index fb304ca..73dac77 100644
--- a/odb/semantics/relational/changelog.cxx
+++ b/odb/semantics/relational/changelog.cxx
@@ -29,6 +29,8 @@ namespace semantics
if (p.attribute<unsigned int> ("version") != 1)
throw parsing (p, "unsupported changelog format version");
+ database_ = p.attribute ("database");
+
// Because things are stored in the reverse order, first save the
// changesets as XML chunks and then re-parse them in the reverse
// order. We have to do it this way so that we can do lookups along
@@ -125,6 +127,7 @@ namespace semantics
{
s.start_element (xmlns, "changelog");
s.namespace_decl (xmlns, "");
+ s.attribute ("database", database_);
s.attribute ("version", 1); // Format version.
// For better readability serialize things in reverse order so that
diff --git a/odb/semantics/relational/changelog.hxx b/odb/semantics/relational/changelog.hxx
index d9e220c..a27c946 100644
--- a/odb/semantics/relational/changelog.hxx
+++ b/odb/semantics/relational/changelog.hxx
@@ -119,7 +119,11 @@ namespace semantics
}
public:
- changelog (): contains_model_ (0) {}
+ string const&
+ database () const {return database_;}
+
+ public:
+ changelog (string const& db): database_ (db), contains_model_ (0) {}
changelog (xml::parser&);
void
@@ -146,6 +150,7 @@ namespace semantics
changelog& operator= (changelog const&);
protected:
+ string database_;
contains_model_type* contains_model_;
contains_changeset_list contains_changeset_;
};