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.
This commit is contained in:
Martin Kleusberg
2013-05-17 14:39:42 +02:00
parent 606b5bd953
commit c251a001a1

View File

@@ -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;
}