diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2011-08-30 16:10:02 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2011-08-30 16:10:02 +0200 |
commit | 3f64781802deb7f910a37e3998cfc358b65e24e9 (patch) | |
tree | a233fb0387c35149cc5d72965db730b531822580 /odb/mysql/connection.hxx | |
parent | 19109c06566ecc1b2a42820145c784d12ad26b27 (diff) |
Implement uniform handle management across all databases
Also use the auto_handle template instead of the raw handle in connection,
statement, and result classes. This removes a lot of brittle "exception
safety guarantee" code that we had in those classes.
Diffstat (limited to 'odb/mysql/connection.hxx')
-rw-r--r-- | odb/mysql/connection.hxx | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/odb/mysql/connection.hxx b/odb/mysql/connection.hxx index f4462ed..3667c10 100644 --- a/odb/mysql/connection.hxx +++ b/odb/mysql/connection.hxx @@ -18,6 +18,7 @@ #include <odb/mysql/version.hxx> #include <odb/mysql/forward.hxx> #include <odb/mysql/transaction-impl.hxx> +#include <odb/mysql/auto-handle.hxx> #include <odb/details/shared-ptr.hxx> @@ -124,7 +125,7 @@ namespace odb alloc_stmt_handle (); void - free_stmt_handle (MYSQL_STMT*); + free_stmt_handle (auto_handle<MYSQL_STMT>&); private: connection (const connection&); @@ -142,11 +143,18 @@ namespace odb bool failed_; MYSQL mysql_; - MYSQL* handle_; + auto_handle<MYSQL> handle_; statement* active_; + + // Keep statement_cache_ after handle_ so that it is destroyed before + // the connection is closed. + // std::auto_ptr<statement_cache_type> statement_cache_; + // List of "delayed" statement handles to be freed next time there + // is no active statement. + // typedef std::vector<MYSQL_STMT*> stmt_handles; stmt_handles stmt_handles_; }; |