mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-05-08 04:49:58 -05:00
improve the fix on the broken execute query transaction
should now do the same as before, but with working rollback and commit
This commit is contained in:
@@ -767,6 +767,7 @@ void MainWindow::executeQuery()
|
|||||||
const char *tail = utf8Query.data();
|
const char *tail = utf8Query.data();
|
||||||
int sql3status = 0;
|
int sql3status = 0;
|
||||||
QString statusMessage;
|
QString statusMessage;
|
||||||
|
bool modified = false;
|
||||||
|
|
||||||
//Accept multi-line queries, by looping until the tail is empty
|
//Accept multi-line queries, by looping until the tail is empty
|
||||||
do
|
do
|
||||||
@@ -822,8 +823,12 @@ void MainWindow::executeQuery()
|
|||||||
statusMessage = tr("%1 Rows returned from: %2").arg(rownum).arg(queryPart);
|
statusMessage = tr("%1 Rows returned from: %2").arg(rownum).arg(queryPart);
|
||||||
case SQLITE_OK:
|
case SQLITE_OK:
|
||||||
{
|
{
|
||||||
|
if( !queryPart.trimmed().startsWith("SELECT", Qt::CaseInsensitive) )
|
||||||
|
{
|
||||||
|
modified = true;
|
||||||
statusMessage = tr("Query executed successfully: %1").arg(queryPart);
|
statusMessage = tr("Query executed successfully: %1").arg(queryPart);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
statusMessage = QString::fromUtf8((const char*)sqlite3_errmsg(db._db)) +
|
statusMessage = QString::fromUtf8((const char*)sqlite3_errmsg(db._db)) +
|
||||||
@@ -842,6 +847,9 @@ void MainWindow::executeQuery()
|
|||||||
ui->queryResultTableView->resizeColumnsToContents();
|
ui->queryResultTableView->resizeColumnsToContents();
|
||||||
|
|
||||||
} while( tail && *tail != 0 && (sql3status == SQLITE_OK || sql3status == SQLITE_DONE));
|
} while( tail && *tail != 0 && (sql3status == SQLITE_OK || sql3status == SQLITE_DONE));
|
||||||
|
|
||||||
|
if(!modified)
|
||||||
|
db.revert(); // better rollback, if the logic is not enough we can tune it.
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::mainTabSelected(int tabindex)
|
void MainWindow::mainTabSelected(int tabindex)
|
||||||
|
|||||||
Reference in New Issue
Block a user