From c251a001a1319060d57aff5f625a8d46c78ed0b5 Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Fri, 17 May 2013 14:39:42 +0200 Subject: [PATCH] DBBrowserDB: Fix transaction logic in execute{Multi}SQL Create a restore point in executeSQL and executeMultiSQL instead of just setting the dirty flag. This way the changes made using these functions are not applied immediately when no restore point was created yet. --- src/sqlitedb.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sqlitedb.cpp b/src/sqlitedb.cpp index acd9c9b9..b5d43ce8 100644 --- a/src/sqlitedb.cpp +++ b/src/sqlitedb.cpp @@ -343,7 +343,7 @@ bool DBBrowserDB::executeSQL ( const QString & statement, bool dirtyDB, bool log if (_db){ if (logsql) logSQL(statement, kLogMsg_App); - if (dirtyDB) setDirty(true); + if (dirtyDB) setRestorePoint(); if (SQLITE_OK==sqlite3_exec(_db,statement.toUtf8(), NULL,NULL,&errmsg)){ ok=true; @@ -368,6 +368,10 @@ bool DBBrowserDB::executeMultiSQL(const QString& statement, bool dirty, bool log if(log) logSQL(statement, kLogMsg_App); + // Set DB to dirty/create restore point if necessary + if(dirty) + setRestorePoint(); + // Show progress dialog int statement_size = statement.size(); QProgressDialog progress(QObject::tr("Executing SQL..."), @@ -417,10 +421,6 @@ bool DBBrowserDB::executeMultiSQL(const QString& statement, bool dirty, bool log } } while(tail && *tail != 0 && (res == SQLITE_OK || res == SQLITE_DONE)); - // Set dirty flag - if(dirty) - setDirty(true); - // Exit return true; }