Revert to savepoint when applicable, also after failed statements

The end of the function is unified for failed and successful cases, so
the savepoint reversion is always made when it has to be.

Reported in issue #2073
This commit is contained in:
mgrojo
2019-12-30 20:33:33 +01:00
parent 81ee07355d
commit b4e8898dfa

View File

@@ -157,6 +157,7 @@ bool RunSql::executeNextStatement()
queries_left_to_execute = QByteArray(tail);
lk.unlock();
QString error;
if (sql3status == SQLITE_OK)
{
sql3status = sqlite3_step(vm);
@@ -227,18 +228,10 @@ bool RunSql::executeNextStatement()
case SQLITE_MISUSE:
break;
default:
QString error = QString::fromUtf8(sqlite3_errmsg(pDb.get()));
releaseDbAccess();
emit statementErrored(error, execute_current_position, end_of_current_statement_position);
stopExecution();
return false;
error = QString::fromUtf8(sqlite3_errmsg(pDb.get()));
}
} else {
QString error = QString::fromUtf8(sqlite3_errmsg(pDb.get()));
releaseDbAccess();
emit statementErrored(error, execute_current_position, end_of_current_statement_position);
stopExecution();
return false;
error = QString::fromUtf8(sqlite3_errmsg(pDb.get()));
}
// Release the database
@@ -256,6 +249,12 @@ bool RunSql::executeNextStatement()
savepoint_created = false;
}
if(!error.isEmpty())
{
emit statementErrored(error, execute_current_position, end_of_current_statement_position);
stopExecution();
return false;
}
// Update the start position for the next statement and check if we are at
// the end of the part we want to execute. If so, stop the execution now.
execute_current_position = end_of_current_statement_position;