From 50b160227bda6194422c668676f3d8610d30a060 Mon Sep 17 00:00:00 2001 From: Peinthor Rene Date: Thu, 28 Mar 2013 10:55:09 +0100 Subject: [PATCH] only revert if the db wasn't dirty before otherwise we might have reverted pre execute query transactions --- src/MainWindow.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index c656db12..1c5f22f8 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -768,6 +768,13 @@ void MainWindow::executeQuery() int sql3status = 0; QString statusMessage; bool modified = false; + bool wasdirty = db.getDirty(); + + // there is no choice, we have to start a transaction before + // we create the prepared statement, otherwise every executed + // statement will get committed after the prepared statement + // gets finalized, see http://www.sqlite.org/lang_transaction.html + db.setRestorePoint(); //Accept multi-line queries, by looping until the tail is empty do @@ -777,12 +784,6 @@ void MainWindow::executeQuery() queryResultListModel->setHorizontalHeaderLabels(QStringList()); queryResultListModel->setVerticalHeaderLabels(QStringList()); - // there is no choice, we have to start a transaction before - // we create the prepared statement, otherwise every executed - // statement will get committed after the prepared statement - // gets finalized, see http://www.sqlite.org/lang_transaction.html - db.setRestorePoint(); - const char* qbegin = tail; sql3status = sqlite3_prepare_v2(db._db,tail,utf8Query.length(), &vm, &tail); @@ -848,7 +849,7 @@ void MainWindow::executeQuery() } while( tail && *tail != 0 && (sql3status == SQLITE_OK || sql3status == SQLITE_DONE)); - if(!modified) + if(!modified && !wasdirty) db.revert(); // better rollback, if the logic is not enough we can tune it. }