On 05/05/2013 12:53 AM, Simon Slavin wrote:
On 4 May 2013, at 6:43pm, Igor Korot <ikoro...@gmail.com> wrote:
If I start a transaction and there will be a failure for whatever reason,
do I have to call ROLLBACK?
Or this transaction will just stay somewhere in a journal and will not go
to db?
Reading from the end of
<http://www.sqlite.org/lang_transaction.html>
it looks like if anything fails you should be issuing a ROLLBACK. It may be
required, and if it isn't required, it does no harm, though the ROLLBACK
command itself will return another error which, presumably, you can always
safely ignore.
This is right.
If an error occurs while executing a statement within an
explicit transaction, there are two possible outcomes:
1) The entire transaction is rolled back, or
2) Any writes made by the failed statement are rolled
back, but the outer transaction remains open.
Which actually occurs depends on exactly what kind of error,
and where in the SQLite code it is encountered. Sometimes it
is possible to leave the transaction open, and sometimes it
needs to be rolled back.
If an error occurs while a transaction is open, then an app
can use sqlite3_get_autocommit() to determine if the transaction
was automatically rolled back or not.
http://www.sqlite.org/c3ref/get_autocommit.html
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users