diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2012-03-07 10:21:09 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2012-03-07 10:21:09 +0200 |
commit | d2fc34834f0b7660374f78d4409e24a165950c2c (patch) | |
tree | 28fd2e0c9b257a5e39d9e29a176472304f51eed1 | |
parent | 729992078ad2840791d74a7a61113bce0f7c29ff (diff) |
Use RAII to free select statement results
-rw-r--r-- | odb/oracle/object-result.txx | 12 | ||||
-rw-r--r-- | odb/oracle/statement.cxx | 3 | ||||
-rw-r--r-- | odb/oracle/statement.hxx | 13 | ||||
-rw-r--r-- | odb/oracle/view-result.txx | 6 |
4 files changed, 31 insertions, 3 deletions
diff --git a/odb/oracle/object-result.txx b/odb/oracle/object-result.txx index 19ac6fe..ddc9783 100644 --- a/odb/oracle/object-result.txx +++ b/odb/oracle/object-result.txx @@ -30,6 +30,9 @@ namespace odb } delete image_copy_; + + if (!this->end_) + statement_->free_result (); } template <typename T> @@ -124,7 +127,10 @@ namespace odb } if (statement_->fetch () == select_statement::no_data) + { + statement_->free_result (); this->end_ = true; + } else { cc.callback = &change_callback; @@ -186,6 +192,9 @@ namespace odb } delete image_copy_; + + if (!this->end_) + statement_->free_result (); } template <typename T> @@ -249,7 +258,10 @@ namespace odb } if (statement_->fetch () == select_statement::no_data) + { + statement_->free_result (); this->end_ = true; + } else { cc.callback = &change_callback; diff --git a/odb/oracle/statement.cxx b/odb/oracle/statement.cxx index 2a08566..8cf2452 100644 --- a/odb/oracle/statement.cxx +++ b/odb/oracle/statement.cxx @@ -1337,9 +1337,6 @@ namespace odb void select_statement:: execute () { - if (!done_) - free_result (); - { odb::tracer* t; if ((t = conn_.transaction_tracer ()) || diff --git a/odb/oracle/statement.hxx b/odb/oracle/statement.hxx index f26aa42..ed8f298 100644 --- a/odb/oracle/statement.hxx +++ b/odb/oracle/statement.hxx @@ -192,6 +192,19 @@ namespace odb bool done_; }; + struct LIBODB_ORACLE_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_ORACLE_EXPORT insert_statement: public statement { public: diff --git a/odb/oracle/view-result.txx b/odb/oracle/view-result.txx index 4f1d01e..64d949e 100644 --- a/odb/oracle/view-result.txx +++ b/odb/oracle/view-result.txx @@ -24,6 +24,9 @@ namespace odb } delete image_copy_; + + if (!this->end_) + statement_->free_result (); } template <typename T> @@ -87,7 +90,10 @@ namespace odb } if (statement_->fetch () == select_statement::no_data) + { + statement_->free_result (); this->end_ = true; + } else { cc.callback = &change_callback; |