diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2013-09-10 14:10:45 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2013-09-17 12:04:01 +0200 |
commit | 31fd2870497686667f20b2d43467a07482f8ab40 (patch) | |
tree | 9e8fc08cd23b52699c62149f665f32df8892c7c1 /odb/sqlite/statement-cache.txx | |
parent | c3248cd60418cee935508f62a3436970f9d234b2 (diff) |
Schema versioning support
Diffstat (limited to 'odb/sqlite/statement-cache.txx')
-rw-r--r-- | odb/sqlite/statement-cache.txx | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/odb/sqlite/statement-cache.txx b/odb/sqlite/statement-cache.txx index 4c6e3cd..8d8e358 100644 --- a/odb/sqlite/statement-cache.txx +++ b/odb/sqlite/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/sqlite/database.hxx> + namespace odb { namespace sqlite @@ -15,6 +17,16 @@ namespace odb typename object_traits_impl<T, id_sqlite>::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 ()) |