Skip to content

Commit

Permalink
Set savepoint before logging the SQL statement
Browse files Browse the repository at this point in the history
Otherwise the sequence of savepoint and update statement is inverted in the
SQL log.

See issue  sqlitebrowser#1859
  • Loading branch information
mgrojo committed Jun 21, 2020
1 parent 3485a52 commit f4d78ad
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/sqlitedb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1002,8 +1002,8 @@ bool DBBrowserDB::executeSQL(const std::string& statement, bool dirtyDB, bool lo
return false;
}

if (logsql) logSQL(QString::fromStdString(statement), kLogMsg_App);
if (dirtyDB) setSavepoint();
if (logsql) logSQL(QString::fromStdString(statement), kLogMsg_App);

char* errmsg;
if (SQLITE_OK == sqlite3_exec(_db, statement.c_str(), callback ? callbackWrapper : nullptr, &callback, &errmsg))
Expand Down Expand Up @@ -1422,8 +1422,8 @@ bool DBBrowserDB::updateRecord(const sqlb::ObjectIdentifier& table, const std::s
else
sql += "sqlb_make_single_value(" + sqlb::joinStringVector(sqlb::escapeIdentifier(pks), ",") + ")=" + sqlb::escapeString(rowid.toStdString());

logSQL(QString::fromStdString(sql), kLogMsg_App);
setSavepoint();
logSQL(QString::fromStdString(sql), kLogMsg_App);

// If we get a NULL QByteArray we insert a NULL value, and for that
// we can pass NULL to sqlite3_bind_text() so that it behaves like sqlite3_bind_null()
Expand Down

0 comments on commit f4d78ad

Please sign in to comment.