From 1c1544f5297f88bbbcbbad2d21c4ec7b62bb9a28 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 30 Aug 2011 16:10:02 +0200 Subject: 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. --- odb/sqlite/connection.cxx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'odb/sqlite/connection.cxx') diff --git a/odb/sqlite/connection.cxx b/odb/sqlite/connection.cxx index 68b57f9..7b16547 100644 --- a/odb/sqlite/connection.cxx +++ b/odb/sqlite/connection.cxx @@ -29,15 +29,6 @@ namespace odb namespace sqlite { connection:: - ~connection () - { - statement_cache_.reset (); // Free prepared statements. - - if (sqlite3_close (handle_) == SQLITE_BUSY) - assert (false); // Connection has outstanding prepared statements. - } - - connection:: connection (database_type& db, int extra_flags) : odb::connection (db), db_ (db), @@ -58,7 +49,11 @@ namespace odb if ((f & SQLITE_OPEN_FULLMUTEX) == 0) f |= SQLITE_OPEN_NOMUTEX; - if (int e = sqlite3_open_v2 (n.c_str (), &handle_, f, 0)) + sqlite3* h (0); + int e (sqlite3_open_v2 (n.c_str (), &h, f, 0)); + handle_.reset (h); + + if (e != SQLITE_OK) { if (handle_ == 0) throw bad_alloc (); @@ -98,6 +93,11 @@ namespace odb statement_cache_.reset (new statement_cache_type (*this)); } + connection:: + ~connection () + { + } + transaction_impl* connection:: begin () { -- cgit v1.1