summaryrefslogtreecommitdiff
path: root/libsqlitepp/sqlite-connection.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libsqlitepp/sqlite-connection.cpp')
-rw-r--r--libsqlitepp/sqlite-connection.cpp57
1 files changed, 12 insertions, 45 deletions
diff --git a/libsqlitepp/sqlite-connection.cpp b/libsqlitepp/sqlite-connection.cpp
index a284a2e..6545918 100644
--- a/libsqlitepp/sqlite-connection.cpp
+++ b/libsqlitepp/sqlite-connection.cpp
@@ -8,9 +8,7 @@ SQLite::ConnectionError::ConnectionError(sqlite3 * db) :
{
}
-SQLite::Connection::Connection(const std::string & str) :
- txDepth(0),
- rolledback(false)
+SQLite::Connection::Connection(const std::string & str)
{
if (sqlite3_open(str.c_str(), &db) != SQLITE_OK) {
ConnectionError err(db);
@@ -25,58 +23,27 @@ SQLite::Connection::~Connection()
}
void
-SQLite::Connection::finish() const
+SQLite::Connection::beginTxInt()
{
- if (txDepth != 0) {
- rollbackTx();
- throw DB::TransactionStillOpen();
+ if (sqlite3_exec(db, "BEGIN TRANSACTION", NULL, NULL, NULL) != SQLITE_OK) {
+ throw Error(db);
}
}
-int
-SQLite::Connection::beginTx() const
-{
- if (txDepth == 0) {
- if (sqlite3_exec(db, "BEGIN TRANSACTION", NULL, NULL, NULL) != SQLITE_OK) {
- throw Error(db);
- }
- rolledback = false;
- }
- return ++txDepth;
-}
-
-int
-SQLite::Connection::commitTx() const
+void
+SQLite::Connection::commitTxInt()
{
- if (rolledback) {
- return rollbackTx();
- }
- if (--txDepth == 0) {
- if (sqlite3_exec(db, "COMMIT TRANSACTION", NULL, NULL, NULL) != SQLITE_OK) {
- throw Error(db);
- }
+ if (sqlite3_exec(db, "COMMIT TRANSACTION", NULL, NULL, NULL) != SQLITE_OK) {
+ throw Error(db);
}
- return txDepth;
}
-int
-SQLite::Connection::rollbackTx() const
+void
+SQLite::Connection::rollbackTxInt()
{
- if (--txDepth == 0) {
- if (sqlite3_exec(db, "ROLLBACK TRANSACTION", NULL, NULL, NULL) != SQLITE_OK) {
- throw Error(db);
- }
- }
- else {
- rolledback = true;
+ if (sqlite3_exec(db, "ROLLBACK TRANSACTION", NULL, NULL, NULL) != SQLITE_OK) {
+ throw Error(db);
}
- return txDepth;
-}
-
-bool
-SQLite::Connection::inTx() const
-{
- return txDepth;
}
DB::BulkDeleteStyle