From efe87a4b6ecee76d01cad8c83eed937a836f6190 Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Tue, 11 Nov 2014 19:14:58 +0100 Subject: [PATCH] Clear result view in Execute SQL tab when running a PRAGMA statement Clear the result table view in the Execute SQL tab of the main window when a PRAGMA statement was executed that didn't return any rows. Before this, running e.g. 'PRAGMA table_info(test)' and then 'PRAGMA table_info(tset)' would still present the result from the first query even though the second should have cleared the view. See issue #151. --- src/MainWindow.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp index 25e15106..7cb7c871 100644 --- a/src/MainWindow.cpp +++ b/src/MainWindow.cpp @@ -745,8 +745,10 @@ void MainWindow::executeQuery() sqlite3_finalize(vm); // SQLite returns SQLITE_DONE when a valid SELECT statement was executed but returned no results. To run into the branch that updates - // the status message and the table view anyway manipulate the status value here. - if(queryPart.trimmed().startsWith("SELECT", Qt::CaseInsensitive) && sql3status == SQLITE_DONE) + // the status message and the table view anyway manipulate the status value here. This is also done for PRAGMA statements as they (sometimes) + // return rows just like SELECT statements, too. + if((queryPart.trimmed().startsWith("SELECT", Qt::CaseInsensitive) || + queryPart.trimmed().startsWith("PRAGMA", Qt::CaseInsensitive)) && sql3status == SQLITE_DONE) sql3status = SQLITE_ROW; switch(sql3status)