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.
This commit is contained in:
Martin Kleusberg
2014-11-11 19:14:58 +01:00
parent 3bc93af7e0
commit efe87a4b6e

View File

@@ -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)