diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2012-03-07 10:21:07 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2012-03-07 10:21:07 +0200 |
commit | 9542fdc4434c3af3eaed91bf10e5b487044d8cc7 (patch) | |
tree | 93a09e5995fee093cc048e585c29c3d88937dbdb /odb/mysql/statement.hxx | |
parent | 6b9ed661b4bf7f1a07ee34fe205d3e0802df535c (diff) |
Use RAII to free select statement results
Diffstat (limited to 'odb/mysql/statement.hxx')
-rw-r--r-- | odb/mysql/statement.hxx | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/odb/mysql/statement.hxx b/odb/mysql/statement.hxx index 9ab95e8..700a7f5 100644 --- a/odb/mysql/statement.hxx +++ b/odb/mysql/statement.hxx @@ -146,6 +146,7 @@ namespace odb private: bool end_; bool cached_; + bool freed_; std::size_t rows_; std::size_t size_; @@ -156,6 +157,19 @@ namespace odb std::size_t result_version_; }; + struct LIBODB_MYSQL_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_MYSQL_EXPORT insert_statement: public statement { public: |