Hi All We have some legacy code which calls sqlite3_exec with ROLLBACk every time sqlite3_step fails irrespective what specific error occurred. I am wondering if this is a safe behavior or should I change this. Can it cause any sideeffects or memory leak or any other issues ?
What is the right thing to do ? I do see some recommendation here https://www.sqlite.org/lang_transaction.html, For all of these errors, SQLite attempts to undo just the one statement it was working on and leave changes from prior statements within the same transaction intact and continue with the transaction. However, depending on the statement being evaluated and the point at which the error occurs, it might be necessary for SQLite to rollback and cancel the entire transaction. An application can tell which course of action SQLite took by using thesqlite3_get_autocommit()<https://www.sqlite.org/c3ref/get_autocommit.html> C-language interface. It is recommended that applications respond to the errors listed above by explicitly issuing a ROLLBACK command. If the transaction has already been rolled back automatically by the error response, then the ROLLBACK command will fail with an error, but no harm is caused by this. Should I be using get_autocommit to determine if rollback is necessary or just calling rollback every time is ok or should I be calling rollback only for errors FULL,IOERR,BUSY and NOMEM. -Mayank