aboutsummaryrefslogtreecommitdiff
path: root/odb/sqlite/polymorphic-object-result.txx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2012-10-15 13:17:30 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2012-10-19 11:40:30 +0200
commit8112bd0febcfa1e3a76e0d03363facbefc3822f7 (patch)
tree0f5a05b9b29ae7d77e95f7831c214b385aaf6a3b /odb/sqlite/polymorphic-object-result.txx
parentd94948b8bccfd8748245726487d54c41bb199baf (diff)
Implement early connection release
Diffstat (limited to 'odb/sqlite/polymorphic-object-result.txx')
-rw-r--r--odb/sqlite/polymorphic-object-result.txx28
1 files changed, 21 insertions, 7 deletions
diff --git a/odb/sqlite/polymorphic-object-result.txx b/odb/sqlite/polymorphic-object-result.txx
index 0dd68cf..8e09bf1 100644
--- a/odb/sqlite/polymorphic-object-result.txx
+++ b/odb/sqlite/polymorphic-object-result.txx
@@ -22,12 +22,26 @@ namespace odb
}
template <typename T>
+ void polymorphic_object_result_impl<T>::
+ invalidate ()
+ {
+ if (!this->end_)
+ {
+ statement_->free_result ();
+ this->end_ = true;
+ }
+
+ params_.reset ();
+ statement_.reset ();
+ }
+
+ template <typename T>
polymorphic_object_result_impl<T>::
polymorphic_object_result_impl (
const query_base& q,
const details::shared_ptr<select_statement>& st,
statements_type& sts)
- : base_type (sts.connection ().database ()),
+ : base_type (sts.connection ()),
result_impl_base (q, st),
statements_ (sts)
{
@@ -48,7 +62,6 @@ namespace odb
assert (!rsts.locked ());
typename statements_type::auto_lock l (rsts);
- odb::database& db (this->database ());
typename object_traits::image_type& i (statements_.image ());
typename root_traits::image_type& ri (rsts.image ());
@@ -85,7 +98,8 @@ namespace odb
// Insert it as a root pointer (for non-unique pointers, rp should
// still be valid and for unique pointers this is a no-op).
//
- ig.reset (object_traits::pointer_cache_traits::insert (db, id, rp));
+ ig.reset (
+ object_traits::pointer_cache_traits::insert (this->db_, id, rp));
pobj = &pointer_traits::get_ref (p);
current (p);
@@ -106,9 +120,9 @@ namespace odb
}
callback_event ce (callback_event::pre_load);
- pi.dispatch (info_type::call_callback, db, pobj, &ce);
+ pi.dispatch (info_type::call_callback, this->db_, pobj, &ce);
- object_traits::init (*pobj, i, &db);
+ object_traits::init (*pobj, i, &this->db_);
// Initialize the id image and binding and load the rest of the object
// (containers, dynamic part, etc).
@@ -132,14 +146,14 @@ namespace odb
if (&pi != &object_traits::info)
{
std::size_t d (object_traits::depth);
- pi.dispatch (info_type::call_load, db, pobj, &d);
+ pi.dispatch (info_type::call_load, this->db_, pobj, &d);
};
rsts.load_delayed ();
l.unlock ();
ce = callback_event::post_load;
- pi.dispatch (info_type::call_callback, db, pobj, &ce);
+ pi.dispatch (info_type::call_callback, this->db_, pobj, &ce);
ig.release ();
}