aboutsummaryrefslogtreecommitdiff
path: root/odb/sqlite/connection.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2011-08-30 16:10:02 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2011-08-30 16:10:02 +0200
commit1c1544f5297f88bbbcbbad2d21c4ec7b62bb9a28 (patch)
tree10db5dc702376bdc14777e1e7d2afbab0ce8dc10 /odb/sqlite/connection.cxx
parent8568cd25d943636e33ec00a935ad8a67d4876e14 (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/sqlite/connection.cxx')
-rw-r--r--odb/sqlite/connection.cxx20
1 files changed, 10 insertions, 10 deletions
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 ()
{