diff options
-rw-r--r-- | odb/sqlite/object-result.txx | 10 | ||||
-rw-r--r-- | odb/sqlite/statement.hxx | 13 | ||||
-rw-r--r-- | odb/sqlite/view-result.txx | 5 |
3 files changed, 28 insertions, 0 deletions
diff --git a/odb/sqlite/object-result.txx b/odb/sqlite/object-result.txx index a6b4e50..39dcdd7 100644 --- a/odb/sqlite/object-result.txx +++ b/odb/sqlite/object-result.txx @@ -21,6 +21,8 @@ namespace odb object_result_impl<T>:: ~object_result_impl () { + if (!this->end_) + statement_->free_result (); } template <typename T> @@ -88,7 +90,10 @@ namespace odb this->current (pointer_type ()); if (!statement_->next ()) + { + statement_->free_result (); this->end_ = true; + } } template <typename T> @@ -147,6 +152,8 @@ namespace odb object_result_impl_no_id<T>:: ~object_result_impl_no_id () { + if (!this->end_) + statement_->free_result (); } template <typename T> @@ -208,7 +215,10 @@ namespace odb this->current (pointer_type ()); if (!statement_->next ()) + { + statement_->free_result (); this->end_ = true; + } } template <typename T> diff --git a/odb/sqlite/statement.hxx b/odb/sqlite/statement.hxx index cf94c71..0ed8aa8 100644 --- a/odb/sqlite/statement.hxx +++ b/odb/sqlite/statement.hxx @@ -294,6 +294,19 @@ namespace odb binding& result_; }; + struct LIBODB_SQLITE_EXPORT auto_result + { + explicit auto_result (select_statement& s): s_ (s) {} + ~auto_result () {s_.free_result ();} + + private: + auto_result (const auto_result&); + auto_result& operator= (const auto_result&); + + private: + select_statement& s_; + }; + class LIBODB_SQLITE_EXPORT insert_statement: public statement { public: diff --git a/odb/sqlite/view-result.txx b/odb/sqlite/view-result.txx index c240add..49d0e68 100644 --- a/odb/sqlite/view-result.txx +++ b/odb/sqlite/view-result.txx @@ -15,6 +15,8 @@ namespace odb view_result_impl<T>:: ~view_result_impl () { + if (!this->end_) + statement_->free_result (); } template <typename T> @@ -76,7 +78,10 @@ namespace odb this->current (pointer_type ()); if (!statement_->next ()) + { + statement_->free_result (); this->end_ = true; + } } template <typename T> |