From 8112bd0febcfa1e3a76e0d03363facbefc3822f7 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 15 Oct 2012 13:17:30 +0200 Subject: Implement early connection release --- odb/sqlite/polymorphic-object-result.txx | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'odb/sqlite/polymorphic-object-result.txx') 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 + void polymorphic_object_result_impl:: + invalidate () + { + if (!this->end_) + { + statement_->free_result (); + this->end_ = true; + } + + params_.reset (); + statement_.reset (); + } + + template polymorphic_object_result_impl:: polymorphic_object_result_impl ( const query_base& q, const details::shared_ptr& 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 (); } -- cgit v1.1