diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2013-09-10 14:10:45 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2013-09-10 14:10:45 +0200 |
commit | 0ed9ceef3abbd9f4ff786f6a02fe8767780e8c2c (patch) | |
tree | 0bca6f9e302dd92eb4dc9136ab0b826f8fa61aff /odb/mysql/statement-cache.txx | |
parent | 075f64ca84e4e1be22bad30e4974e9b675d12ec8 (diff) |
Schema versioning support
Diffstat (limited to 'odb/mysql/statement-cache.txx')
-rw-r--r-- | odb/mysql/statement-cache.txx | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/odb/mysql/statement-cache.txx b/odb/mysql/statement-cache.txx index 0ac74a4..b110d97 100644 --- a/odb/mysql/statement-cache.txx +++ b/odb/mysql/statement-cache.txx @@ -2,6 +2,8 @@ // copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : GNU GPL v2; see accompanying LICENSE file +#include <odb/mysql/database.hxx> + namespace odb { namespace mysql @@ -15,6 +17,16 @@ namespace odb typename object_traits_impl<T, id_mysql>::statements_type statements_type; + // Clear the cache if the database version has changed. This + // makes sure we don't re-use statements that correspond to + // the old schema. + // + if (version_seq_ != conn_.database ().schema_version_sequence ()) + { + map_.clear (); + version_seq_ = conn_.database ().schema_version_sequence (); + } + map::iterator i (map_.find (&typeid (T))); if (i != map_.end ()) @@ -31,6 +43,9 @@ namespace odb view_statements<T>& statement_cache:: find_view () { + // We don't cache any statements for views so no need to clear + // the cache. + map::iterator i (map_.find (&typeid (T))); if (i != map_.end ()) |