Skip to content

Commit b4e8898

Browse files
committed
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
1 parent 81ee073 commit b4e8898

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

src/RunSql.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ bool RunSql::executeNextStatement()
157157
queries_left_to_execute = QByteArray(tail);
158158
lk.unlock();
159159

160+
QString error;
160161
if (sql3status == SQLITE_OK)
161162
{
162163
sql3status = sqlite3_step(vm);
@@ -227,18 +228,10 @@ bool RunSql::executeNextStatement()
227228
case SQLITE_MISUSE:
228229
break;
229230
default:
230-
QString error = QString::fromUtf8(sqlite3_errmsg(pDb.get()));
231-
releaseDbAccess();
232-
emit statementErrored(error, execute_current_position, end_of_current_statement_position);
233-
stopExecution();
234-
return false;
231+
error = QString::fromUtf8(sqlite3_errmsg(pDb.get()));
235232
}
236233
} else {
237-
QString error = QString::fromUtf8(sqlite3_errmsg(pDb.get()));
238-
releaseDbAccess();
239-
emit statementErrored(error, execute_current_position, end_of_current_statement_position);
240-
stopExecution();
241-
return false;
234+
error = QString::fromUtf8(sqlite3_errmsg(pDb.get()));
242235
}
243236

244237
// Release the database
@@ -256,6 +249,12 @@ bool RunSql::executeNextStatement()
256249
savepoint_created = false;
257250
}
258251

252+
if(!error.isEmpty())
253+
{
254+
emit statementErrored(error, execute_current_position, end_of_current_statement_position);
255+
stopExecution();
256+
return false;
257+
}
259258
// Update the start position for the next statement and check if we are at
260259
// the end of the part we want to execute. If so, stop the execution now.
261260
execute_current_position = end_of_current_statement_position;

0 commit comments

Comments
 (0)