SQLite Forum

[Bug] Use «RETURNING» in transaction cause error 5 on commit.
Login
Did you run the INSERT to completion?  

That is, until it sqlite3_step returned SQLITE_DONE?

If you did not complete execution of the INSERT ... RETURNING statement then of course you cannot COMMIT the transaction.