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 | d3ec68714365046a30379a410cdff52e5f5ae066 (patch) | |
tree | 36b971dd06626cc39b51eb0ec6e7f4f3ca40fcba /odb/mssql/statement-cache.txx | |
parent | 88f3f0282bad25c962783defa1e34dcbec60a07c (diff) |
Schema versioning support
Diffstat (limited to 'odb/mssql/statement-cache.txx')
-rw-r--r-- | odb/mssql/statement-cache.txx | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/odb/mssql/statement-cache.txx b/odb/mssql/statement-cache.txx index 5ab2918..7840227 100644 --- a/odb/mssql/statement-cache.txx +++ b/odb/mssql/statement-cache.txx @@ -2,6 +2,8 @@ // copyright : Copyright (c) 2005-2013 Code Synthesis Tools CC // license : ODB NCUEL; see accompanying LICENSE file +#include <odb/mssql/database.hxx> + namespace odb { namespace mssql @@ -15,6 +17,16 @@ namespace odb typename object_traits_impl<T, id_mssql>::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 ()) |